in reply to Strange int() result
The simplest way to round to a whole number is to add 0.5 before truncating with int:
19:26 >perl -wE "say int(35784.45 * 100); say int(35784.45 * 100 + 0.5 +);" 3578444 3578445 19:27 >
Hope that helps,
Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Strange int() result
by hexcoder (Curate) on Jun 18, 2014 at 21:18 UTC |
In Section
Seekers of Perl Wisdom