Hi all,
I'm writing a JSON parser in pure OCaml and have encountered an issue with small float values:
10 zeros in between
# 1.00000000001e-312 ;;
- : float = 1.00000000001e-312
11 zeros in between
# 1.000000000001e-312 ;;
- : float = 1.00000000000341e-312
# 5e-324 ;;
- : float = 4.94065645841e-324
I haven't found precise limit, but as a rule of thumb (not precise), for a positive float value to keep its precision, it should not be smaller thanĀ 1.00000000001e-312. To use JSON as precise serializer, it would be necessary to preserve accuracy.
For values smaller than the limit above, should I just treat as 2 values: (normalized: float, exponent: float), so we will have:
5e-324 -> (5, -324)
Comments and suggestions are appreciated. Thanks.
--