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

your isInteger function is broken #3

Open
bgdavidx opened this issue Jan 13, 2017 · 0 comments
Open

your isInteger function is broken #3

bgdavidx opened this issue Jan 13, 2017 · 0 comments

Comments

@bgdavidx
Copy link

bgdavidx commented Jan 13, 2017

Your isInteger function breaks for values over 2^31-1:

> function isInteger(x) { return (x^0) === x; } // your function
undefined
> isInteger(Number.MAX_SAFE_INTEGER)
false
> Number.MAX_SAFE_INTEGER
9007199254740991
> function isInteger2(x) { return Math.round(x) === x } // actual working function
undefined
> isInteger2(Number.MAX_SAFE_INTEGER)
true
> Number.isInteger(Number.MAX_SAFE_INTEGER) // ES6 function
true
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