cician / grain-json

JSON library for Grain (https://grain-lang.org)
GNU Lesser General Public License v3.0
10 stars 0 forks source link

Define number semantics #5

Open cician opened 3 years ago

cician commented 2 years ago

Printing: It has been decided to return exception on NaNs and Infs and to return a Result from print functions for this reason. This is done.

Rationals are converted into floats before printing.

Currently using NumberUtils.dtoa to print floats (and rationals). This should be fine, but at the very least many tests are needed to make sure it always results in a valid json number.

Currently waiting for arbitrary precision and decimal number parsing to land in Grain before making a final judgment.

cician commented 2 years ago

Parsing of negative zero value has been mentioned on Grain Discord, but not decided upon. May want to parse as negative floating point heap number in order to preserve meaning after round trip parse->toString.