Excel VBA Double Addition Error

前端 未结 1 916
一整个雨季
一整个雨季 2021-01-24 14:31

I\'m having a hard time explaining this one. The following function is being used as a worksheet formula. A value of \"empty\" simply means that the cell was empty and, theref

1条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-24 15:20

    That error is the result of floating point accuracy problems. Even if your first two values are 0 and 0, it will still have the same result. So will {0.1, 0.2, 0.3, 0.4}.

    Round it to some reasonable number of decimal places before returning it and call it a day.

    0 讨论(0)
提交回复
热议问题