On Epsilon, MachineEpsilon, and relative differences – via: I was wondering, that what is the closest value to the Zero floating point can have – G+
Posted by jpluimers on 2015/10/07
A long time ago, there was an interesting discussion here: I was wondering, that what is the closest value to the Zero floating point can have.
Recently I needed to do some calculations on series where getting close to zero could become a problem.
- Math seems to have an Epsilon of 1E-12.
- Sytem.Types has Epsilon of 1E-30 and Epsilon2 of 1E-40.
- XE4+ FMX has IsEssentiallyZero and IsNotEssentiallyZero for Single values.
In practice it depends a lot on what you are doing. Sometimes absolute Epsilons are best, but at other times relative difference is much more applicable.
Then there is also a Machine Epsilon: a way to derive an Epsilon from a data type that works in all languages and platforms.