All pastes #577019 Raw Edit

Killy

public c v1 · immutable
·published 2007-06-19 19:06 UTC
rendered paste body
#include <stdio.h>#include <float.h>//#include <math.h>static float onef = 1.000000000000000000000e+00;static double one = 1.000000000000000000000e+00;static long double onel = 1.00000000000000000000000000000e+00;int main(void) {    printf("Size of float = %ld\n",sizeof(float));    printf("Size of double = %ld\n",sizeof(double));    printf("Size of long double = %ld\n",sizeof(long double));    printf("one = %g\n",one);    float fx=onef*0.1;    double dx=one*0.1;    long double ldx=onel*0.1;    while(one+dx!=one) dx*=0.1;    printf("DBL_EPSILON = %g\n",DBL_EPSILON);    printf("DX = %g\n",dx);    while(onef+fx!=onef) fx*=0.1;    printf("FLT_EPSILON = %g\n",FLT_EPSILON);    printf("FX = %g\n",fx);    while(onel+ldx!=onel) ldx*=0.1;    printf("LDBL_EPSILON = %g\n",LDBL_EPSILON);    printf("LDX = %g\n",ldx);    return 0;}// Killy$ ./dbl_epsilon Size of float = 4Size of double = 8Size of long double = 12one = 1DBL_EPSILON = 2.22045e-16DX = 1e-16FLT_EPSILON = 1.19209e-07FX = 1e-08LDBL_EPSILON = -0LDX = -2.33511e-15