Language
C
Compiler
gcc 13.2.0
Options
Warnings
C11(GNU)
no pedantic
Raw compiler options
-lm
-O3
-ffast-math
#include <stdio.h>
#include <math.h>
#include <fenv.h>
int main(void) {
long long q;
if (scanf("%lld", &q) != 1) return 1;
double v = sqrt(q);
long double vl = sqrtl(q);
printf("%.40f %.20a\n", v, v);
printf("%.40Lf %.20La\n", vl, vl);
#if defined(FE_DOWNWARD)
puts("setting rounding mode to FE_DOWNWARD");
if (fesetround(FE_DOWNWARD)) return 1;
#elif defined(FE_TOWARDZERO)
puts("setting rounding mode to FE_TOWARDZERO");
if (fesetround(FE_TOWARDZERO)) return 1;
#else
#error appropriate rounding mode unavailable
#endif
double v2 = sqrt(q);
long double vl2 = sqrtl(q);
printf("%.40f %.20a\n", v2, v2);
printf("%.40Lf %.20La\n", vl2, vl2);
return 0;
}
4503599761588224
$ gcc prog.c -Wall -Wextra -std=gnu11 -lm -O3 -ffast-math67108865.0000000000000000000000000000000000000000 0x1.00000040000000000000p+26
67108864.9999999925494194030761718750000000000000 0x8.000001ffffffc0000000p+23
setting rounding mode to FE_DOWNWARD
67108864.9999999850988388061523437500000000000000 0x1.0000003ffffff0000000p+26
67108864.9999999925494194030761718750000000000000 0x8.000001ffffffc0000000p+23
Exit Code:
0