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

Numbers parsing #130

Open
hauleth opened this issue Jan 19, 2014 · 2 comments
Open

Numbers parsing #130

hauleth opened this issue Jan 19, 2014 · 2 comments

Comments

@hauleth
Copy link

hauleth commented Jan 19, 2014

parseInt("1234567890987654321", 10); // => 1234567890987654400
+"1234567890987654321"; // => 1234567890987654400
~~"1234567890987654321" // => -1318314752 
"1234567890987654321" >> 0 // => -1318314752
"1234567890987654321" >>> 0 // => 2976652544

All of them are incorrect, but I would rather expect first two rather than other results.

@rwaldron
Copy link
Owner

I'm not sure what you'd like me to do here; Idiomatic.js is about writing clean, consistent and maintainable code, not about teaching which operations result in integer truncation.

@hauleth
Copy link
Author

hauleth commented Jan 19, 2014

Yeah, but 3.B.2.4 say

parseInt( num, 10 );

// is the same as...

~~num;

num >> 0;

num >>> 0;

What is a little bit too broad.

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