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

logBase 10 floating issues #5

Open
Brandon-Rozek opened this issue Jul 26, 2018 · 0 comments
Open

logBase 10 floating issues #5

Brandon-Rozek opened this issue Jul 26, 2018 · 0 comments

Comments

@Brandon-Rozek
Copy link

I was reading through the code and noticed a TODO item in the function ordersOfMagnitude
-- TODO: logBase 10 1000000 /= 6 but 5, fix this
I noticed that it came from this line
(floor :: Double -> Int) . logBase 10)

There was a discussion on StackOverflow about the logbase 10 issues https://stackoverflow.com/questions/26844123/haskell-logbase-error.

Is there any particular reason why we use floor in this scenario? Since we're always dealing with integer results, perhaps we can implement something similar to what GHC did or even just round in a simpler case.
https://github.com/ghc/packages-integer-gmp/blob/master/GHC/Integer/Logarithms.hs

Thanks for your time!

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

1 participant