Closed SmartHypercube closed 3 years ago
The behaviour is consistent with showFFloat
from Numeric
in base
:
>>> formatScientific Fixed Nothing 100
"100.0"
>>> formatScientific Fixed Nothing 1234.5678
"1234.5678"
>>> formatScientific Fixed Nothing 1234
"1234.0"
>>> formatScientific Fixed (Just 0) 1234
"1234"
>>> showFFloat Nothing 100 ""
"100.0"
>>> showFFloat Nothing 1234.5678 ""
"1234.5678"
>>> showFFloat Nothing 1234 ""
"1234.0"
>>> showFFloat (Just 0) 1234 ""
I don't see a reason to diverge.
I see. Thanks for pointing this out.
But I do think the behavior I proposed is useful in many places too, and currently there are no such functions exported in Data.Scientific
. Some libraries are using the wrong function to do the job (see linked issue above) due to not having the right function available. It would be great if Data.Scientific
exports such a function.
After rethinking this, I believe scientific
is good as it is now. No need for changes.
In my opinion, currently,
formatScientific Fixed Nothing
is a little strange and not very useful.I expect
Nothing
here means "the same asJust n
, with the leastn
that does not cause precision lost". Thus: