Setting FLT_EVAL_METHOD not working

Viewed 688
#include <stdio.h>
#include <float.h>

#ifdef FLT_EVAL_METHOD
    #undef FLT_EVAL_METHOD
    #define FLT_EVAL_METHOD 1
#else
    #define FLT_EVAL_METHOD 1
#endif

int main(void)
{
    printf("%f\n%f\n", FLT_MAX, DBL_MAX);
    float fp = FLT_MAX;
    printf("%f\n", fp + 1);
    printf("%f\n", FLT_MAX + 1);
    printf("%f\n", (float) FLT_MAX + 1);
}

The expected output is:

340282346638528859811704183484516925440.000000
179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000
340282346638528859811704183484516925441.000000
340282346638528859811704183484516925441.000000
340282346638528859811704183484516925441.000000

But the actual output is:

340282346638528859811704183484516925440.000000
179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000
340282346638528859811704183484516925440.000000
340282346638528859811704183484516925440.000000
340282346638528859811704183484516925440.000000

Since FLT_EVAL_METHOD is set to 1, shouldn't all float expressions evaluated as doubles? What does "evaluate float and double as double, and long double as long double." mean? Are floats treated identical to doubles?

1 Answers
Related