TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
 Specialized Dev Zones Research Center eBook Library .NET Java C++ Web Dev Architecture Database Security Open Source Enterprise Mobile Special Reports 10-Minute Solutions DevXtra Blogs Slideshow

# JavaScript: Playing the Numbers Game : Page 4

## Built-in type-conversion in JavaScript makes using numbers so easy that developers rarely even think about using them. Surely that simplicity isn't as perfect as it seems! Just how good is the number support in JavaScript anyway? In this article you'll explore the edges of the world of numbers in JavaScript.

 by Nigel McFarlane
 Sep 5, 2003
 Page 4 of 5

### WEBINAR:On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning

Four Values: Warning Numbers You Need to Know
The million dollar question is: When will your nice integers suddenly become error-prone double precision? Answer: when their magnitude gets too big, or goes between 1 (one) and zero. So, one (1) is the first warning number. 46,340 is the biggest integer which, when multiplied by itself, still fits into 31 or 32 bits. If your script uses multiplication, and your numbers get any bigger than this, you could go over into error-prone floating point. This is your second warning number.

Now, 1,114,111 (seven digits), which is the same as \x41777777 is the biggest Unicode value. Furthermore 16,777,215 (eight digits) = #FFFFFF is the biggest RGB color value. But 2,147,483,647 (ten digits) is the biggest 32-bit signed integer, and -2,147,483,648 is the smallest. Therefore, JavaScript will always store Unicode values and RGB colors as integers inside JavaScript. 2,147,483,647 is the third warning number—any bigger than this and your number is stored in double precision form. 9,007,199,254,740,992 (sixteen digits) is the biggest floating point number that will still look like an integer when printed. All Date objects (calculated in milliseconds) are smaller than this, so they will always print like an integer. This is your fourth warning number.

Finally, 1.7976931348623157e+308 is the largest double-precision number. Beyond this, there's only Infinity.

Comment and Contribute

(Maximum characters: 1200). You have 1200 characters left.

Thanks for your registration, follow us on our social networks to keep up-to-date