"But you should never overestimate the ingenuity of the sceptics to come up with a counter-argument." -Myles Allen
"Think for yourself!" - Abigail
"Time is a poor substitute for thought"--theorbtwo
"Efficiency is intelligent laziness." -David Dunham
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
The problem is NOT within int(..) (I tried 0.501..)
the result of int is correct 12400, but if you devide this (try only10!) you will get 123.99:
$cent = int(0.5 + ($u*$p*100); # => 12400, ok
#but
$dollar = $cent / 100; # => 123.99
# even if you use sprintf (which itself does
# NOT round financially, you have to it yourself!
$dollar = sprintf ".2f", $cent/100; # => 123.99 Dollar