Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Use doubles, use Kahan summation, use 2Sum algo, use larger precision floating point library?


+1 for TwoSum [1]. To expand on that: Kahan summation is an approximation which is a bit cheaper, but not great if some inputs can also be negative. That's because it is basically FastTwoSum(a,b) in a loop, which only works if the exponent of a >= that of b. TwoSum removes this requirement and is not that much more expensive.

[1] https://en.wikipedia.org/wiki/2Sum




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: