Incorrect formatting of decimal values
Closed this issue · 1 comments
Describe the bug
The decimal formatting of some negative rational values is incorrect.
To Reproduce
Welcome to Disco, version 0.1.6!
A language for programming discrete mathematics.
Disco> 0.1 - 0.2
0.-1
Disco> 0.2 * -6
-1.-2
Disco> 0.3 * (-0.3)
0.-11
Expected vs actual behavior
The negative sign should always be to the left of the decimal and appear at most once. The misplacement of the negative sign affects the logic of the formatting, as can be seen in the 0.3 * (-0.3)
example, which has a representation structurally similar to the equal expression -0.1 + 0.01
but not the correct representation -0.09
.
Additional context
After group consideration, the resolution may be to remove decimal representation entirely from the language, or at least extract formatting data from the expressions themselves and into a REPL command, e.g. Disco> :decimal <expr>
.
Apparently this bug has existed, untested, since basically forever. Fortunately the fix looks to be fairly simple. We can leave the issue of removing decimal representation entirely for later.