cognitect / transit-format

A data interchange format.
1.87k stars 36 forks source link

Floating point encoding of NaN and ±∞ #20

Closed jlouis closed 9 years ago

jlouis commented 9 years ago

The IEEE 754 standard defines values for corner-case values:

jlouis@eldar:~/P/plan9/lib$ ocaml
    OCaml version 4.01.0

#1.0 /. 0.0;;
- : float = infinity
# -1.0 /. 0.0;;
- : float = neg_infinity
#0.0 /. 0.0;;
- : float = nan
# 

JSON, however, does not allow these to be represented. How will the format marshal these? I expect we use a ~d tag as in "~dNaN" and so on, but it would be nice to make this explicit.

rickbeerendonk commented 9 years ago

I wrote tests for the current Java implementation proving that indeed "~dNaN", "~d-Infinity" and "~dInfinity" are already working: https://github.com/rickbeerendonk/transit-java/commit/b955bc928499c16aaccdd70f014042b780ed2a7c

I am also writing a CSharp implementation and "~dNaN", "~d-Infinity" and "~dInfinity" will work out of the box: https://github.com/NForza/transit-csharp/commit/ebd9389ba351b7ef098fb5e200d94d529789f17f

timewald commented 9 years ago

This issue has been reported for the transit-clj kit, here: https://github.com/cognitect/transit-clj/issues/7. We're working on a plan to address it.

dchelimsky commented 9 years ago

The "z" tag for special numbers was added to the spec: https://github.com/cognitect/transit-format#ground-and-extension-types for reference.