in reply to [s]printf %d oddity
http://support.microsoft.com/kb/q42980/
http://www-106.ibm.com/developerworks/java/library/j-jtp0114/
edit: and perldoc -q decimal
Updated for clarity, this part added:
Usually, the standard float -> string conversion as used by print() handles these inaccuracies fairly well, but printf("%d") does a "hard" truncate, as you can see here:
This is documented in perlnumber, but the implications can be hard to predict (and hard to debug, since what is printed is not necissarily the same as what is in the number).> perl -e 'print (8.78 * 100 ) 878 > perl -e 'printf("%d", (8.78 * 100 ))' 877
|
|---|