about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorg3xzh <g3xzh@yahoo.com>2013-12-12 01:57:13 +0200
committerg3xzh <g3xzh@yahoo.com>2013-12-19 02:13:51 +0200
commit05395cba88580db10455952706cd8ae292fdbbe7 (patch)
tree8a4b1b4a74b76aba35cd82834a835e252a362532 /src/rustllvm/RustWrapper.cpp
parent4e0cb316fc980f00e1b74f3fdb7a842b540be280 (diff)
downloadrust-05395cba88580db10455952706cd8ae292fdbbe7.tar.gz
rust-05395cba88580db10455952706cd8ae292fdbbe7.zip
Fix `sum()` accuracy
`[1e20, 1.0, -1e20].sum()` returns `0.0`. This happens because during
the summation, `1.0` is too small relative to `1e20`, making it
negligible.

I have tried Kahan summation but it hasn't fixed the problem.
Therefore, I've used Python's `fsum()` implementation with some
help from Jason Fager and Huon Wilson.
For more details, read:
www.cs.cmu.edu/~quake-papers/robust-arithmetic.ps

Moreover, benchmark and unit tests were added.

Note: `Status.sum` is still not fully fixed. It doesn't handle
NaNs, infinities and overflow correctly. See issue 11059:
https://github.com/mozilla/rust/issues/11059
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions