You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
(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?
The text was updated successfully, but these errors were encountered:
It is not so easy to display always a real number as a real. Sometimes it looks like an integer. I know a way to display always a real number as a real in C++ and I let you know about this, but I don't know Rust.
The interpreter prints real numbers like integers if their fractional part is zero.
Example:
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.
1524157875315348200
looks like an integer, when in fact it is a floating point number with limited precision. Printing the number as1524157875315348200.0
would communicate that fact more clearly.Thank you @pgl10 for reporting!
I can see several options to fix this:
.0
at the end but never uses scientific notation (Example).{:g?}
format switch which may never come.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?
The text was updated successfully, but these errors were encountered: