I'm reading the code that someone wrote epsilone()
epsilon()
appears in the associated document as "double type minus 1 from the smallest number greater than 1."
So epsilone()
is the smallest number greater than zero?
Or is there a value that can be expressed as double
within the (0,0+epsilone)
range?
double someValue = ... //assign something
if (someValue < std::numeric_limits<double>::epsilon() &&
someValue > -std::numeric_limits<double>::epsilon()) {
someValue = 0.0;
}
64-bit IEEE double consists of 1-bit sign
, 52-bit mantissa
, and 11-bit extent
.
The first one is
1.000000000000000000000000000000000000000000000000×2^0
The smallest number in water greater than 1 is
1.0000 00000000 00000000 00000000 00000000 00000000 00000001 × 2^0 = 1 + 2^-52
This is.
So epsilon
= (1+2^-52) - 1
= 2^-52
It is.
There are many values within the (0, epilon)
range that can be expressed as double
.
the smallest positive factor
1.0000 00000000 00000000 00000000 00000000 00000000 00000000 × 2^-1022 = 2^-1022
Starting with
There are about (1022 - 52 + 1)×2^52 = 4372995238176751616
.
© 2024 OneMinuteCode. All rights reserved.