wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes Javascript Numbers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Javascript Numbers" Watch "Javascript Numbers" New topic
Author

Javascript Numbers

Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I just stubbed my toe on something interesting. I have a Java long field in an object graph that I convert to JSON with StringTree, giving me something like:

When I e-v-a-l() that string, I get an object with key=400004535727393900. Now I read that all Javascript numbers are floats and I guess I went over the number of significant digits.

Am I going to have to make a String copy of this field? Or limit my longs to 16 digits?


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61430
    
  67

This might be helpful.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Thanks, that's where I read that all numbers are floats, but skipped right by the 15 digits remark. Must have been in shock at the time.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61430
    
  67

Blame caffeine.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Javascript Numbers