Thread: What is EPS?

  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
    6,815
    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>).
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

Popular pages Recent additions subscribe to a feed