-
Notifications
You must be signed in to change notification settings - Fork 30
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
Feature request: toBiggestInt #34
Comments
What is the Haskell implementation you are refering to? I suspect that it might support arbitrary precision floats. In fact the value that you report for saturation it seems very close to highest possible value for a
Regarding your implementation it seems ok, although it might not be the most efficient since for big numbers the latest addition might not change the float much. Looking around I found a nice discussion in Julia (summary: you just need the highest 54 bits of precision since this is what a float64 can represent) where a more performant implementation is proposed and later merged. We could take inspiration for that in order to put a update: maxFloat64 in nimfrom the hex representation of a max float64 wikipedia, here is a way to echo max float64 in nim (playground): import strutils
echo cast[float64]("0x7FEFFFFFFFFFFFFF".parseHexInt) output:
Note that |
Fixes Feature request: toBiggestInt nim-lang#34
I need to convert
BigInt
tofloat64
and I'm not sure I'm qualified to implement it.I'm using this:
But it gives me different results from a Haskell implementation as it get close to saturating the float at 179769313486231560835325876058105298516207002341652166261661174625869553267292326574530099287946549246750631490335877017522087105926987962906277604735569213290190919152394180476217125334960946356387261286640198029037799514183602981511756283727771403830521483963923935633133642802139091669457927874464075218945.
The text was updated successfully, but these errors were encountered: