Share via


numeric_limits::epsilon

The function returns the difference between 1 and the smallest value greater than 1 that is representable for the data type.

static Type epsilon( ) throw( );

Return Value

The difference between 1 and the smallest value greater than 1 that is representable for the data type.

Remarks

The value is FLT_EPSILON for type float. epsilon for a type is the smallest positive floating-point number N such that N + epsilon + N is representable.

Example

// numeric_limits_epsilon.cpp
// compile with: /EHsc
#include <iostream>
#include <limits>

using namespace std;

int main( )
{
   cout << "The difference between 1 and the smallest "
        << "value greater than 1\n for float objects is: " 
        << numeric_limits<float>::epsilon( ) 
        << endl;
   cout << "The difference between 1 and the smallest "
        << "value greater than 1\n for double objects is: " 
        << numeric_limits<double>::epsilon( ) 
        << endl;
   cout << "The difference between 1 and the smallest "
        << "value greater than 1\n for long double objects is: " 
        << numeric_limits<long double>::epsilon( ) 
        << endl;
}
The difference between 1 and the smallest value greater than 1
 for float objects is: 1.19209e-007
The difference between 1 and the smallest value greater than 1
 for double objects is: 2.22045e-016
The difference between 1 and the smallest value greater than 1
 for long double objects is: 2.22045e-016

Requirements

Header: <limits>

Namespace: std

See Also

Reference

strstreambuf Class