Double.Epsilon vs. std :: numeric_limits <double> :: min ()

Why double.Epsilon != std::numeric_limits<double>::min()?

On my PC: double.Epsilon == 4.9406564584124654E-324and is defined in .NET. std::numeric_limits<double>::min() == 2.2250738585072014e-308

Is there a way to get 2.2250738585072014e-308 from .NET?

+3
source share
3 answers

They are different because they double.Epsilonreturn the smallest representable value. numeric_limits<double>::min()returns the smallest normalized value.

Mostly double.Epsilonequivalent numeric_limits<double>::denorm_min().

The easiest way to get the equivalent in .NET is probably to design a bit pattern for the minimum normalized number and use it BitConverter.Int64BitsToDouble.

+9
source

, ++/CLI :

double epsilon() { return std::numeric_limits<double>::min(); }

? ? .

+1

Epsilon is the smallest possible difference between two doubles. (Edit: not exact, this is the minimum positive non-zero number in this case).

double.MinValue

- This is what you need.

-2
source

Source: https://habr.com/ru/post/1706444/


All Articles