in reply to Different values while applying format specifiers

See: What Every Computer Scientist Should Know About Floating-Point Arithmetic.

If I run

printf("%.16f\n",100 * 5.1);
I get the output
509.9999999999999400
The difference is that normal print does a formatted round (I think %.8g) that rounds up to 510, whereas %d casts it as a signed integer, a.k.a. performs a floor and rounds down to 509.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.