1

I am trying to printf a long double value in C, but it doesn't give the correct value. I have tried using different format parameters, but I'm not sure what to make of the output. I read from some other answers that it might be a problem with the compiler/OS, but I haven't managed to solve the problem.

I use cygwin GCC compiler on windows 7.

#include <stdio.h>
long double ans;

int main(){
    ans = 1.2457473567352;
    printf("long double ans = %.20Lf \n",ans);
}

The output:

long double ans = 0.000000000000000
long double ans = 1.133046674395481e-317
Joel Wong
  • 69
  • 9

0 Answers0