PDA

View Full Version : 17 digits limit?



Kor
Mar 19th, 2007, 03:42 PM
I have a question, especially for liorean, who looks to be a true mathematician. Is there a way to bypass the 17 digits limit rounding in javascript calculation paradigm? Is there a 16_to_17 barrier? If so, is that barrier available in other languages as well. If yes/no, why?

liorean
Mar 19th, 2007, 04:30 PM
Actually, I've only got the equivalent to high school math studies behind me. JKD is the math guy... I do have some specific knowledge due to interest in, and experience with, programming languages but no formal education.

The JavaScript Number type is IEEE 754 double precision floating point. (Which is the native floating point number type that is used in most modern CPUs.) The physical limits on this number type are general to all languages that use this number type. Which means practically all languages.
The specific behaviour for the string-number-string roundtripping may be slightly different between the various languages, though.

The limit can be bypassed in the same way that other languages bypass it, writing a BigDecimal, BigNumber or BigInteger format. The problem with this approach is that JavaScript doesn't provide true arrays and integers, so any such functionality will probably have to build on using double internally. And this will cost a lot performance wise.


I can also add, I've discussed the Number format with you before, as well as with others. Not sure how much I can add. If you haven't ready the links in those posts you probably should, though.

Kor
Mar 19th, 2007, 11:38 PM
The problem with this approach is that JavaScript doesn't provide true arrays and integers, so any such functionality will probably have to build on using double internally. ]
This is what I was looking for... If so, I'll dig for it.