Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
$i = 1.255 $j = $i * 100 + 0.5 $j = $j * 10000000 <p> print $j <p> -> 1260000000 <p> print int ( $j ) <p> -> 1259999999
Is there a way to make perl behave as a humble user of arithmetics would have expected, without needing additional modules like Math::Round?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to use the int-function?
by kennethk (Abbot) on Jan 03, 2011 at 15:00 UTC | |
|
Re: How to use the int-function?
by moritz (Cardinal) on Jan 03, 2011 at 15:02 UTC | |
|
Re: How to use the int-function?
by ikegami (Patriarch) on Jan 03, 2011 at 19:42 UTC | |
|
Re: How to use the int-function?
by Ratazong (Monsignor) on Jan 03, 2011 at 15:04 UTC | |
by Anonymous Monk on Jan 03, 2011 at 15:29 UTC | |
by kennethk (Abbot) on Jan 03, 2011 at 15:41 UTC | |
by Anonymous Monk on Jan 03, 2011 at 15:53 UTC | |
by kennethk (Abbot) on Jan 03, 2011 at 16:07 UTC | |
| |
by ruzam (Curate) on Jan 03, 2011 at 19:30 UTC | |
by Anonymous Monk on Jan 04, 2011 at 08:48 UTC | |
by kennethk (Abbot) on Jan 04, 2011 at 18:14 UTC |