Why double.Epsilon != std::numeric_limits<double>::min()?
On my PC:
double.Epsilon == 4.9406564584124654E-324 and is defined in .NET
std::numeric_limits<double>::min() == 2.2250738585072014e-308
Is there a way to get 2.2250738585072014e-308 from .NET?
They're different because double.Epsilon returns the smallest representable value. numeric_limits<double>::min() returns the smallest normalized value.
Basically double.Epsilon is the equivalent to numeric_limits<double>::denorm_min().
The easiest way of getting the equivalent in .NET is probably to work out the bit pattern for the minimal normalized number and use BitConverter.Int64BitsToDouble.
Well you could use C++/CLI to return the value:
double epsilon() { return std::numeric_limits<double>::min(); }
Why would you want to though? Why do they have to be the same? You should try to avoid skating on the edges of your floating point numbers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With