i just started using floats. Why does this:
Code:
#include <stdio.h>
int main () {
int X=1,i;
float x;
for (i=0;i<20;i++) {
x=(float)X/10;
printf("%d %f %d\t",X,x,i);
x+=0.1f;
X=x*10;
printf("%d %f \n",X,x);
}
return 0;
}
do this???:
Code:
1 0.100000 0 2 0.200000
2 0.200000 1 3 0.300000
3 0.300000 2 4 0.400000
4 0.400000 3 5 0.500000
5 0.500000 4 6 0.600000
6 0.600000 5 7 0.700000
7 0.700000 6 8 0.800000
8 0.800000 7 9 0.900000
9 0.900000 8 10 1.000000
10 1.000000 9 11 1.100000
11 1.100000 10 12 1.200000
12 1.200000 11 13 1.300000
13 1.300000 12 13 1.400000
13 1.300000 13 13 1.400000
13 1.300000 14 13 1.400000
13 1.300000 15 13 1.400000
13 1.300000 16 13 1.400000
13 1.300000 17 13 1.400000
13 1.300000 18 13 1.400000
13 1.300000 19 13 1.400000