浮点数计算误差

做个笔记,几个wiki还有stackoverflow的回答串联起来理解

1) https://en.wikipedia.org/wiki/Floating-point_arithmetic#Accuracy_problems

2) https://stackoverflow.com/questions/13542944/how-many-significant-digits-do-floats-and-doubles-have-in-java

3) https://en.wikipedia.org/wiki/Single-precision_floating-point_format

4) https://en.wikipedia.org/wiki/Round-off_error

5) https://en.wikipedia.org/wiki/Machine_epsilon

几个原则:

1)避免超大数和超小数之间的运算;

2)大量重复和累计运算会引入误差;

3)根据算法本身特点,因地制宜选用合适的数据类型,例如矩阵求逆,微分近似求导,用double型。否则误差可能很大。

posted @ 2020-03-04 17:55  IT屁民  阅读(215)  评论(0编辑  收藏  举报