My problem is my IDE (I don't know; maybe it can be the compiler etc.) doesn't recognize double and long double data types properly.
This is my basic example:
#include <stdio.h>
#include <stdlib.h>
int main()
{
double x=1.126462842684262264;
long double y=1.126462842684262264;
printf("x = %lf \n",x);
printf("x = %f \n",x);
printf("y = %lf \n",y);
printf("y = %Lf \n",y);
return 0;
}
The output is
x = 1.126463
x = 1.126463
y = 1.126463
y = 1.126463
Process returned 0 (0x0) execution time : 0.019 s
Press any key to continue.
Normally, long double precision's is 19 decimal places and double precision's is 15 decimal places. Why that happens and how to fix it?
- I am using GNU GCC compiler.
- My IDE is CodeBLocks.