Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inc-mixed has off by one error #7

Open
jwoptio opened this issue May 4, 2020 · 0 comments
Open

inc-mixed has off by one error #7

jwoptio opened this issue May 4, 2020 · 0 comments

Comments

@jwoptio
Copy link

jwoptio commented May 4, 2020

From the example:

var incMixed = require('number-theory').incMixed;

// A number representing a mixed-radix "clock" at 11:59 PM
var number = [59, 59, 23];

// The bases for each of the mixed radix digits (60 seconds to a minute,
// 60 minutes to an hour, 24 hours to a day).
var base = [60, 60, 24];

incMixed(number, base); // Returns [0, 0, 0] (or midnight the next day)

Should return [0,0,0] but in fact returns [60, 59, 23].

I think the <= comparison on line 25 of inc-mixed should just be <.

On the same note - I feel like maybe incrementing past the point where we know the base of the next position should throw an overflow error instead of resetting back to 0. Not sure about that but something to think about.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant