It depends upon what you mean by "precision level".
Floating-point numbers have "regular" (normal) values, but there are special, sub-normal numbers as well. If you want to find out different limits, the C standard has predefined constants:
#include <math.h>
#include <stdio.h>
#include <float.h>
int main(void)
{
printf("%30s: %g\n", "FLT_EPSILON", FLT_EPSILON);
printf("%30s: %g\n", "FLT_MIN", FLT_MIN);
printf("%30s: %g\n", "nextafterf(0.0, 1.0)", nextafterf(0.0, 1.0));
printf("%30s: %g\n", "nextafterf(1.0, 2.0)-1", (nextafterf(1.0, 2.0) - 1.0f));
puts("");
printf("%30s: %g\n", "DBL_EPSILON", DBL_EPSILON);
printf("%30s: %g\n", "DBL_MIN", DBL_MIN);
printf("%30s: %g\n", "nextafter(0.0, 1.0)", nextafter(0.0, 1.0));
printf("%30s: %g\n", "nextafter(1.0, 2.0)-1", (nextafter(1.0, 2.0) - 1.0));
puts("");
printf("%30s: %Lg\n", "LDBL_EPSILON", LDBL_EPSILON);
printf("%30s: %Lg\n", "LDBL_MIN", LDBL_MIN);
printf("%30s: %Lg\n", "nextafterl(0.0, 1.0)", nextafterl(0.0, 1.0));
printf("%30s: %Lg\n", "nextafterl(1.0, 2.0)-1", (nextafterl(1.0, 2.0) - 1.0));
return 0;
}
The above program prints 4 values for each type:
- the difference between 1 and the least value greater than 1 in that type (TYPE
_EPSILON
),
- the minimum positive normalized value in a given type (TYPE
_MIN
). This does not include subnormal numbers,
- the minimum positive value in a given type (
nextafter
*(0
...)
). This includes subnormal numbers,
- the minimum number greater than 1. This is the same as TYPE
_EPSILON
, but calculated in a different way.
Depending upon what you mean by "precision", any or none of the above can be useful to you.
Here is the output of the above program on my computer:
FLT_EPSILON: 1.19209e-07
FLT_MIN: 1.17549e-38
nextafterf(0.0, 1.0): 1.4013e-45
nextafterf(1.0, 2.0)-1: 1.19209e-07
DBL_EPSILON: 2.22045e-16
DBL_MIN: 2.22507e-308
nextafter(0.0, 1.0): 4.94066e-324
nextafter(1.0, 2.0)-1: 2.22045e-16
LDBL_EPSILON: 1.0842e-19
LDBL_MIN: 3.3621e-4932
nextafterl(0.0, 1.0): 3.6452e-4951
nextafterl(1.0, 2.0)-1: 1.0842e-19