Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change formatScientific Fixed Nothing behavior #80

Closed
SmartHypercube opened this issue Sep 25, 2021 · 3 comments
Closed

change formatScientific Fixed Nothing behavior #80

SmartHypercube opened this issue Sep 25, 2021 · 3 comments

Comments

@SmartHypercube
Copy link

In my opinion, currently, formatScientific Fixed Nothing is a little strange and not very useful.

I expect Nothing here means "the same as Just n, with the least n that does not cause precision lost". Thus:

formatScientific Fixed Nothing 100 = formatScientific Fixed (Just 0) 100 = "100"
formatScientific Fixed Nothing 1234 = formatScientific Fixed (Just 0) 1234 = "1234"
formatScientific Fixed Nothing 1234.5678 = formatScientific Fixed (Just 4) 1234.5678 = "1234.5678"
@phadej
Copy link
Collaborator

phadej commented Nov 1, 2021

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.

@SmartHypercube
Copy link
Author

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.

@SmartHypercube
Copy link
Author

After rethinking this, I believe scientific is good as it is now. No need for changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants