[erlang-questions] No JSON/MAPS interoperability in 17.0?
Sat Mar 15 17:17:17 CET 2014
On 15 Mar 2014, at 16:58, Loïc Hoguin <essen@REDACTED> wrote:
> On 03/14/2014 12:55 PM, Joe Armstrong wrote:
>> 1) does a floating point number survive a round-trip from erlang
>> -> JSON -> Erlang
>> is it "bit identical" after the round trip? - why does this
>> matter? - well it
>> might just matter - I might want to cache the result or
>> compute a SHA1 from it.
> I'm not sure you can guarantee this if the encoding/decoding happens on different architectures, can you? Is a 64bit floating point number the same on Intel, AMD, ARM, GPUs, FPGAs and so on?
In the most general sense, no.
However, in 2014, you can pretty much assume that floating point implementation in living CPUs complies with IEEE 754.
Especially so with the format used for 32- and 64-bit floating point (binary32 and binary64 in IEEE 754).
The IBM zSeries (was /360, /370, i.e. the "mainframe") is the only major remaining architecture that has a different 64-bit binary floating point format (“hexadecimal floating point”, it now also does support IEEE formats, and of course, it additionally features IEEE 754 decimal floating point, but that is a different animal). The Vax had its own formats, but that only lives on in the now also outdated Alpha. A few more architectures with pre-754 floating point formats only exist in emulation platforms now (Univac, anyone?). And, of course, all bets are off in special-purpose embedded hardware/DSPs.
(Note that Erlang only seems to support part of IEEE 754 (no non-finites), and the minor differences that are found in partially-compliant embedded platforms often are in the support of non-finites only.)
More information about the erlang-questions