I'd like to understand why the two methods of summing a list of floating point numbers differs by exactly 32.0?
import mathnums = [26015151255025000.,26015151255025000.,26015151255025000.,26015151255025000.,26015151255025000.,26015151255025000.,26015151255025000.,26015151255025000.,26015151255025000.]math_fsum_result = math.fsum(nums)loop_result = 0.0for n in nums: loop_result += nprint(format(math_fsum_result, '.1f'))print(format(loop_result, '.1f'))
Which produces:
234136361295224992.0
234136361295224960.0
It is understood that both are accumulating rounding errors but the inconsistency of exactly 32.0 seems weird.
For the record the correct value calculated with decimals is:
234136361295225000.0