Like Tree1Likes
  • 1 Post By grumpy

What is EPS?

This is a discussion on What is EPS? within the C++ Programming forums, part of the General Programming Boards category; What is EPS? Are there any function in C++ for EPS? How do I output a value with eps 1e-12?...

  1. #1
    Registered User
    Join Date
    Jan 2013
    Posts
    114

    What is EPS?

    What is EPS? Are there any function in C++ for EPS? How do I output a value with eps 1e-12?

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    5,851
    EPS is a set of three letters. It could mean anything.

    One relatively common meaning is that it is shorthand for "machine epsilon", which 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.

    In C, machine epsilon is specified in the standard header <float.h>, with the names FLT_EPSILON, DBL_EPSILON, and LDBL_EPSILON. Those three macros give the machine epsilon for the float, double, and long double types, respectively.

    In C++, similar macros are available in the standard header <cfloat> (as C's <float.h> is deprecated in C++). The preferred (by some) way in C++ is to use std::numeric_limits<floating_point_type>::epsilon( ) - specified in the standard header <limits>. For example, machine epsilon for the float type is std::numeric_limits<float>::epsilon(). Yes, epsilon() is a member function of std::numeric_limits<float>, so the brackets are required.

    There is no requirement that the machine epsilon have a value of 1e-12. The actual value depends on the floating point type.

    If you want to print out a value that small to an output stream (like std::out) look up the setw() and setprecision() steam manipulators (both are specified in standard header <iomanip>).
    King Mir likes this.
    Right 98% of the time, and don't care about the other 3%.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21