"sum([1.0, 1e100, 1.0, -1e100])" fails

Try

using KahanSummation

sum_kbn([1.0, 1e100, 1.0, -1e100])

which was earlier in Base IIUC. Related thread.

Edit: you’ll also find AccurateArithmetics and the interesting task to extend error-free transformations.

9 Likes