8
I'm having trouble understanding the output of this program
int main()
{
double x = 1.8939201459282359e-308;
double y = 4.9406564584124654e-324;
printf("%23.16e\n", 1.6*y);
printf("%23.16e\n", 1.7*y);
printf("%23.16e\n", 1.8*y);
printf("%23.16e\n", 1.9*y);
printf("%23.16e\n", 2.0*y);
printf("%23.16e\n", x + 1.6*y);
printf("%23.16e\n", x + 1.7*y);
printf("%23.16e\n", x + 1.8*y);
printf("%23.16e\n", x + 1.9*y);
printf("%23.16e\n", x + 2.0*y);
}
The output is
9.8813129168249309e-324
9.8813129168249309e-324
9.8813129168249309e-324
9.8813129168249309e-324
9.8813129168249309e-324
1.8939201459282364e-308
1.8939201459282364e-308
1.8939201459282369e-308
1.8939201459282369e-308
1.8939201459282369e-308
I'm using IEEE arithmetic. The variable y holds the smallest possible IEEE number. The first five prints show a number which is twice y as I would expect. What is confusing me is that the next five prints show different numbers. If 1.6*y is the same as 2.0*y then how can x + 1.6*y be different from x + 2.0*y?