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

added solution supporting Number.MAX_SAFE_INTEGER #6

Closed
wants to merge 1 commit into from
Closed

added solution supporting Number.MAX_SAFE_INTEGER #6

wants to merge 1 commit into from

Conversation

cameroncooper
Copy link

No description provided.

@cameroncooper
Copy link
Author

modulo is not as fast as bitshifting, but is still fast

bitshift x 62,655,640 ops/sec ±0.95% (83 runs sampled)
modulo x 34,084,258 ops/sec ±0.96% (87 runs sampled)
Math.floor x 14,786,517 ops/sec ±2.06% (81 runs sampled)
parseInt x 14,127,969 ops/sec ±0.66% (88 runs sampled)
Fastest is bitshift

@cameroncooper cameroncooper mentioned this pull request Mar 23, 2016
@tjmehta
Copy link
Owner

tjmehta commented Mar 23, 2016

what about adding additional equality checks:

return (x >> 0 === x && x >> 0 > 0) || x === Number.MAX_VALUE || x === Number.MAX_SAFE_INTEGER

@fearphage
Copy link
Contributor

FYI, all the tests are synchronous and don't need to use the done callback.

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

Successfully merging this pull request may close these issues.

None yet

3 participants