Closed
Description
The interpreter prints real numbers like integers if their fractional part is zero.
Example:
>> 1.0
1
With small numbers this is no big deal but it may cause confusion if the fractional part is lost due to the limited precision of the floating point representation.
>> (define a 1234567890.12)
>> (* a a)
1524157875315348200
1524157875315348200
looks like an integer, when in fact it is a floating point number with limited precision. Printing the number as 1524157875315348200.0
would communicate that fact more clearly.
Thank you @pgl10 for reporting!
I can see several options to fix this:
- (easy) Use the debug formatter, which prints floats with
.0
at the end but never uses scientific notation (Example). - (easy) Wait for the
{:g?}
format switch which may never come. - (moderate) Implement custom formatting to properly show the available precision.
- (trivial) Leave as it is, arguing that the user should not be concerned with the internal implementation of numbers. This argument breaks down for large numbers.
At the moment, I prefer the first option. The trailing zeros are a bit ugly for large numbers but it's so easy to implement.
Any thoughts?