More Precise Floating point Data Types than double?

前端 未结 4 1911
情歌与酒
情歌与酒 2020-12-31 15:20

In my project I have to compute division, multiplication, subtraction, addition on a matrix of double elements. The problem is that when the size of matrix incr

4条回答
  •  时光说笑
    2020-12-31 15:52

    You might want to consider the sequence of operations, i.e. do the additions in an ordered sequence starting with the smallest values first. This will increase overall accuracy of the results using the same precision in the mantissa:

    1e00 + 1e-16 + ... + 1e-16 (1e16 times) = 1e00
    1e-16 + ... + 1e-16 (1e16 times) + 1e00 = 2e00
    

    The point is that adding small numbers to a large number will make them disappear. So the latter approach reduces the numerical error

提交回复
热议问题