Son icon indicating copy to clipboard operation
Son copied to clipboard

Have we made a mistake by forbidding exponential notation?

Open seagreen opened this issue 7 years ago • 4 comments

If anyone using JSON requires exponential notation please let me know here.

seagreen avatar Mar 17 '17 16:03 seagreen

For scientific software you might work with large numbers. Forbidding exponential notation might mean adding 300 insignificant digits to your json file. Worst case your file could be composed of 99% useless data.

impact27 avatar Dec 10 '17 11:12 impact27

If you had to choose between not allowing exponential notation or allowing only exponential notation, for machine-to-machine communication it makes more sense to me to choose the latter, honestly. It's a far more natural representation of floating point data.

mwerezak avatar Dec 10 '17 13:12 mwerezak

I second the call to allow only exponential notation. This is very much needed in engineering.

For readability, i would use engineering notation (exponent are signed multiples of 3) , but that's debatable.

In other notes i wouldn't recommend disallowing trailing zeros. These are used to convey information about precision (significant figures). While that can be done in other ways, it's often unknown, if trailing zeros represent significance or not and information could be accidentially thrown away.

ChristianKurz avatar Dec 10 '17 15:12 ChristianKurz

@impact27: Good point, I'll think about that some more. The current simplicity of the EBNF and railroad diagram would be sad to give up, but we would definitely gain something from it.

@mwerezak: JSON Numbers aren't floats (though they can represent them), and I don't want to privilege floats over any of the other things they can represent.

@shorty66: You're looking for a different project from Son. I share your feelings and think it would have been great if the various JSON parsers in the wild respected that 1.0e2 and 1.00e2 are two different JSON Numbers. Unfortunately many of them just munge them into the same value. The Son strategy is: "sometimes you need to give up, since we can't trust that parsers will treat these things differently it's best not to keep the extraneous features around". But Son isn't meant for all use cases, and it would be cool to see projects that actually use those features to good effect.

seagreen avatar Dec 10 '17 16:12 seagreen