On Sep 19, 2008, at 10:25 AM, Kris Zyp wrote:
>>> Consider 1.1m instead of 1m.
>
> Would be:
> '{"foo":1.1}'
Ok, how about serializing the object you get by evaluating {"foo":0.1
+0.2}?
>> JSON does not provide for decimal, and receiver-makes-it-wrong is
>> a bug.
>> JSON would need to be extended to handle decimal reliably.
>
> No, JSON only provides for decimal, JSON uses radix 10 to encode
> numbers,
Of course it uses base 10 for encoding and parsing, but the RFC says
nothing about the required precise value of a number in any
representation -- including in base 10.
> it
> has no support for binary. JSON doesn't need to be extended (unless
> you want
> to see binary added, but I don't that would be popular).
All JSON codecs today (AFAIK -- all the ones written in JS) use 64-
bit double precision, not any kind of decimal, to represent numbers.
> JSON makes no
> assertions about what format a receiver must use to store the
> numbers it
> receives, it transfers numbers in decimal format, and
> implementations can
> and should be able to use any format they desire to internally
> represent it
> based on their needs and expectations.
Conversion plus rounding means that a JSON peer may not be able to
ignore storage format, which is double. It's possible that real JSON-
based apps depend on this de-facto standard. At any rate, under-
specification in the RFC allows it, and via Postel's Law it is likely
that apps *do* depend on double being the storage format.
> Today implementations do vary in
> which format they choose to use,
Do you know of any that use decimal or any format other than IEEE 754
double?
> but there is no restriction preventing
> implementations from using decimal formats for de-serialization of
> numbers,
> and it seems like it would make sense for JavaScript to do so when
> decimals
> become available.
Could be. Best case, there's no significantly-used web app or page
that depends on JSON peers storing using double. We just do not know.
/be
_______________________________________________
Es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss