PDA

View Full Version : Large numbers rounded off?



jeremym
18 Apr 2012, 12:14 PM
I'm not sure if this is an Ext thing or a javascript thing, but I have a store that contains a multi-tiered object and one of the values in it is a large number (for example: 7737164832469684451 ... I've confirmed that this is the value in the json that comes back from the server... however when I try to access this value in the store, it instead comes back as 7737164832469684000 ... I checked with some other similarly large numbers and they all rounded off as well. I'm assuming I'll need to ask the server to return the value as a string... will this happen to all numbers larger than 2^32 ? Is this an ext limitation or a javascript limitation?

jeremym
18 Apr 2012, 1:05 PM
Doh! marked my response as the answer rather than yours... not sure how to fix that (tried deleting the post... that didn't do it...) ...

Looks like its a javascript limitation, thanks!

scottmartin
18 Apr 2012, 1:05 PM
If you enter the number in the console, you will get the new result.



> num = 7737164832469684451
7737164832469684000


Regards,
Scott.

lorezyra
18 Apr 2012, 5:24 PM
This is a limit of JavaScript itself... Check out this library if you need to handle large numbers...

https://github.com/silentmatt/javascript-biginteger