One of the things that we cared quite a bit when creating OData and datajs is taking into account many of the little gotchas that you can find with JavaScript.
For example, numbers in JavaScript can be integers or floating-point, but there are no different data types for these. However, to keep things simple, they have a common range of precision: you get 53 bits of "exact" numbers, and after that the decimal separator starts floating around and you lose the less important digits.
Of course this means that if you're moving 64-bit values around, this can be pretty catastrophic. You can see in the OData protocol site, however, that 64-bit values are represented as strings in JSON. This means that there's no risk of some processing component losing data inadvertently.
You can see in http://visitmix.com/LabNotes/The-Latest-Twitpocolypse that this issues does in fact come up in practice, but with OData and datajs, you're covered.
Enjoy!
Source: http://blogs.msdn.com/b/marcelolr/archive/2011/04/04/javascript-numbers-bits-and-strings.aspx
No comments:
Post a Comment