Closed junderw closed 1 year ago
This method of converting large unsigned integers into f64 is more accurate, but from my rough benchmarks, for most numbers there's at least a 3x slow down, and for some numbers (that work well with the simple method currently used) it's as much as a 10x slow down for speed.
Thanks for mentioning this.
We should probably add benchmarks here as well to compare. Anyway, i also think we should favour correctness.
And probably a fuzzer test to check that it is correct now…
Thanks for the ping @ordian -- I see that no tests have been changed and everything is passing, so I imagine the calculation has not changed so much in the end. Seems fine by me!
Hmm, actually I don't see CI checks running, maybe a fluke with GitHub CI.
@junderw could you please merge recent master?
Rebased on master.
Based off of this blog post: https://blog.m-ou.se/floats/ (I tried to get the gist of this into the comments, but it's kind of long.)
This method of converting large unsigned integers into f64 is more accurate, but from my rough benchmarks, for most numbers there's at least a 3x slow down, and for some numbers (that work well with the simple method currently used) it's as much as a 10x slow down for speed.
Sacrificing speed for accuracy.
Please close if this is a trade off that's not acceptable.
I'd assume anyone dealing with floats is not expecting accuracy, but at the same time, I'm not too sure exactly how the current method's inaccuracies will manifest themselves.
Anywho, I was doing this work for another PR and thought it might be useful here.