Machine Epsilon is the smallest number of EPS (epsilon) such that 1 + EPS not equal to 1. 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.
In C, machine epsilon is specified in the standard header 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. The preferred way in C++ is to use std::numeric_limits::epsilon( ) – specified in the standard header .
In Java, it is referred to as ULP (unit in last place). You can find it by using the java.lang.Math package and the Math.ulp() method.
In Python3, the information is available in sys.float_info, which corresponds to float.h in C99.
This is c++ equivalent of std::numeric_limits::epsilon( ).
>>> import sys
Machine Epsilon is : 1.19209e-07
Note that the above result varies from machine to machine.
This article is contributed by Sahil Rajput. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Program for Sum of the digits of a given number
- Quine - A self-reproducing program
- Program to compute Log n
- Output of C++ Program | Set 10
- Output of C++ Program | Set 14
- Output of C++ Program | Set 16
- Output of C++ Program | Set 18
- Program to print last 10 lines
- Program to validate an IP address
- Write a C program that does not terminate when Ctrl+C is pressed
- Write a C program that won't compile in C++
- Write a program that produces different results in C and C++
- OpenCV C++ Program to play a video
- OpenCV C++ Program to blur a Video
- OpenCV C++ Program to create a single colored blank image