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

100000000000000000000000000000000000000000000000000000000 #2

Closed
hueitan opened this issue Aug 23, 2015 · 6 comments
Closed

100000000000000000000000000000000000000000000000000000000 #2

hueitan opened this issue Aug 23, 2015 · 6 comments

Comments

@hueitan
Copy link

hueitan commented Aug 23, 2015

var num = 100000000000000000000000000000000000000000000000000000000;

parseInt(num, 10) === num; // => false
@parshap
Copy link
Owner

parshap commented Aug 24, 2015

Thanks for the report. This is interesting.

> parseInt(1000000000000000000000, 10)
1
> parseInt("1000000000000000000000", 10)
1000000000000000000000

The native Number.isInteger returns true for 1000000000000000000000, so we should make sure this polyfill does too. I will think about the best solution — any ideas?

parshap added a commit that referenced this issue Aug 24, 2015
parseInt() fails with big numbers - instead use Math.floor() to
determine if the number is an integer.

Fixes #2.
parshap added a commit that referenced this issue Aug 24, 2015
parseInt() fails with big numbers - instead use Math.floor() to
determine if the number is an integer.

Fixes #2.
@hueitan
Copy link
Author

hueitan commented Aug 25, 2015

Convert the number to string before doing parse?

@parshap
Copy link
Owner

parshap commented Aug 27, 2015

Fixed and released in is-integer@1.0.5. Thanks for reporting!

@hueitan
Copy link
Author

hueitan commented Aug 27, 2015

Still fail on 100000000000000000.1

@parshap
Copy link
Owner

parshap commented Aug 27, 2015

That's because 100000000000000000.1 is not representable in JavaScript.

> 100000000000000000.1
100000000000000000

@parshap
Copy link
Owner

parshap commented Aug 28, 2015

Sorry, forgot to npm publish 1.0.5, but did just now.

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

2 participants