Help Dealing with Numbers in Double Type
Hi,
For some reason I am having trouble manipulating large double numbers in C. For example, with the following code:
Code:
#include <stdio.h>
#include <math.h>
int main(){
double x;
x = pow(2,100);
printf("%lf\n",x);
x = x + 111111111111.00;
printf("%lf\n",x);
return 0;
}
The output is:
1267650600228229401496703205376.000000
1267650600228229401496703205376.000000
Which means "x" is not changing at all. The same problem happens when I try to divide "x" by 10. The division will be performed (and one digit will be removed), but the number itself will change (i.e., I'll lose the initial number).
Does anyone know what I am doing wrong?
Thanks