4 ms·
'inf' and 'nan' should work fine. If I understand your suggestion correctly, you would like ieee floating point inf, -inf, and nan to be representable as token
by fnord123 9y ago
'inf' and 'nan' should work fine.
If I understand your suggestion correctly, you would like ieee floating point inf, -inf, and nan to be representable as tokens as though they are numbers. It makes sense as that's how ieee floats do it. But in JSON they aren't numbers, so they aren't represented as numbers.
From the spec:
"""
JSON is agnostic about numbers. In any programming language, there can be a variety of number types of
various capacities and complements, fixed or floating, binary or decimal. That can make interchange between
different programming languages difficult. JSON instead offers only the representation of numbers that
humans use: a sequence of digits. All programming languages know how to make sense of digit sequences
even if they disagree on internal representations. That is enough to allow interchange.
"""
- echlebek 9y agoI'm not suggesting anything, I'm fully aware of the spec. I'm just pointing out that you can't represent NaN and Inf in JSON. Strings don't count.