Description
AFAIK, SOM doesn't specify how floating point numbers should be converted to strings, so there is almost certainly inconsistency across implementations. To my surprise, printing floating point numbers turns out to be an active area of research, with the recent best algorithm appearing only in 2018. yksom
uses an implementation of Ryū to print out floating point numbers and it is subtly different than java-som. Consider the program:
(1.1 + 1) println.
(1.1 + 1.2) println.
(1.1 + (1 << 30)) println.
(1.1 + (1 << 60)) println.
(1 + 1.1) println.
(-1 - 1.1) println.
(-1 - -1.1) println.
(-1 * -1.1) println.
(10 / 1.3) println.
(10 / 0.3) println.
(10 / 0.2) println.
java-som prints:
2.1
2.3
1.0737418251E9
1.15292150460684698E18
2.1
-2.1
0.10000000000000009
1.1
7
33
50
whereas yksom prints:
2.1
2.3
1073741825.1
1.152921504606847e18
2.1
-2.1
0.10000000000000009
1.1
7
33
50
i.e. 1.0737418251E9 -> 1073741825.1.
There are C and Java implementations of Ryū, so it is probably feasible to specify that's how floating point numbers should be printed? I admit this is a small issue in the grand scheme of things, at most, but it does make it harder to test multiple SOM variants.