This type of question can be resolved by reading a paper entitled What Every Computer Scientist Should Know About Floating-Point Arithmetic.
Your machine uses a binary representation for floating-point numbers which cannot exactly represent the rational number 3/1000 = 0.003.
Of course, the machine can print its approximation of 0.003 as "0.003"
, but that's being done by the formatted printing code inside printf
, when it rounds off the value to a given number of decimal digits.
The difference between the printed, decimal versions of floating-point values and their actual internal values can create problems for the programmer or user who isn't aware of the issues.