Two pieces of code. One uses n = n - 1; One uses --n; One works; One doesn't
output
145 23.900000 24.070000
144 24.070000 24.110001
143 24.110001 23.200001
142 23.200001 23.400000
141 23.400000 22.940001
140 22.940001 23.440001
139 23.440001 24.530001
138 24.530001 24.709999
137 24.709999 23.990000
136 23.990000 24.530001
135 24.530001 25.129999
134 25.129999 24.129999
output
169 53.209999 53.209999
168 54.799999 54.799999
167 54.750000 54.750000
166 54.759998 54.759998
165 53.880001 53.880001
164 53.860001 53.860001
163 53.450001 53.450001
162 52.930000 52.930000
161 51.259998 51.259998
160 51.099998 51.099998
159 51.349998 51.349998
Code:
while( n !=0)
{
n = n -1;
printf(" %d %f %f\n",n,price[l][n+1], price[l][n]);
}
output
145 23.900000 24.070000
144 24.070000 24.110001
143 24.110001 23.200001
142 23.200001 23.400000
141 23.400000 22.940001
140 22.940001 23.440001
139 23.440001 24.530001
138 24.530001 24.709999
137 24.709999 23.990000
136 23.990000 24.530001
135 24.530001 25.129999
134 25.129999 24.129999
Code:
while( n !=0)
{//n = n -1;
printf("%d %f %f\n", n,price[l][n], price[l][--n]);
}
169 53.209999 53.209999
168 54.799999 54.799999
167 54.750000 54.750000
166 54.759998 54.759998
165 53.880001 53.880001
164 53.860001 53.860001
163 53.450001 53.450001
162 52.930000 52.930000
161 51.259998 51.259998
160 51.099998 51.099998
159 51.349998 51.349998