I experience different rounding of numbers in printf
depending on conditions I don't understand.
printf('%1.0f\n',0.5)
printf('%1.1f\n',0.05)
printf('%1.2f\n',0.005)
printf('%1.3f\n',0.0005)
printf('%1.0f\n',1.5)
printf('%1.1f\n',1.05)
printf('%1.2f\n',1.005)
printf('%1.3f\n',1.0005)
Gives me the following output:
0
0.1
0.01
0.001
2
1.1
1.00
1.000
Why is 0.0005
rounded to 0.001
, but 1.0005
to 1.000
?