Floating PointImprecision
Previous slide
Next slide
Back to first slide
View graphic version
main()
{
int i;
float x;
double y;
printf("\nFloats:\n");
for( i=0; i <= 9; i++ ){
x = 1.0 + (i / 10.0);
printf("Expect 1.%d - actual is %.42f\n",
i, x);
}
printf("\nDoubles:\n");
for( i=0; i <= 9; i++ ){
y = 1.0 + (i / 10.0);
printf("Expect 1.%d - actual is %.42f\n",
i, y);
}
}