Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Javascript Numbers

 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This might be helpful.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Blame caffeine.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic