Machine Epsilon is a machine-dependent floating point value that provides an upper bound on relative error due to rounding in floating point arithmetic. Mathematically, for each floating point type, it is equivalent to the difference between 1.0 and the smallest representable value that is greater than 1.0.
The std::numeric_limits ::digits function is used to find the number of radix digits that the data type can represent without loss of precision.
Numeric limits type. Provides information about the properties of arithmetic types (either integral or floating-point) in the specific platform for which the library compiles.
Data types that supports std::numeric_limits() in C++ std::numeric_limits<int>::max() gives the maximum possible value we can store in type int. std::numeric_limits<unsigned int>::max()) gives the maximum possible value we can store in type unsigned int.
I don't have any good reference about std::numeric_limits<T>
, but sites on the net says that std::numeric_limits<T>::epsilon()
will return the difference between 1
and the smallest number after it. As far as I know about the int
type, the next numer after 1
is 2
, so epsilon should be 1
. But it's 0
(Linux, g++ 4.4.5). What is the reasoning behind that?
I know that in practice epsilon()
is only useful for floating point types, I'm just nitpicking.
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