Where do I find the machine epsilon in C#?

前端 未结 5 1908
暖寄归人
暖寄归人 2020-12-29 08:01

The machine epsilon is canonically defined as the smallest number which added to one, gives a result different from one.

There is a Double.Epsilon but t

5条回答
  •  甜味超标
    2020-12-29 08:38

    Ref. the routine in Meonester's: Actually the value of machEps on exit from the do ... while loop is such that 1+machEps == 1. To obtain the machine epsilon we must go back to the previous value, by adding the following after the loop: machEps *= 2.0D; This will return 2.2204460492503131e-16 in agreement with the recommendation in Microsoft's documentation for Double.Epsilon.

提交回复
热议问题