Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
65
rated 0 times [  71] [ 6]  / answers: 1 / hits: 17079  / 11 Years ago, wed, july 24, 2013, 12:00:00

When I do this:



var x = parseInt(–2147483648);
console.log(x);


I get the value as:



NaN


Why does this happen?



I want to test if a number is in the range of C (int), so I am doing the above, but it does not work. Also, I want to do this for C (long), is there a way to this?



For example:
If I do:



var x = parseInt(-9223372036854775808);
console.log(x);


Now, I know that (-+)2^53 is the limit of numbers in Javascript. Is there some other way to test if the given value in a form is actually in the range of long or int?


More From » nan

 Answers
23

It should work fine, the problem is that you're using the wrong character, an ndash vs a hyphen -:



var x = parseInt(-2147483648);
console.log(x);


If you copy/paste that you'll see that it works now.


[#76794] Monday, July 22, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
raveno

Total Points: 453
Total Questions: 92
Total Answers: 92

Location: France
Member since Thu, Oct 27, 2022
2 Years ago
raveno questions
;