in reply to Re: How to use the int-function?
in thread How to use the int-function?
In the following view on the problem, I try to round the number 1.255, and try to get the result 1.26. How would you perform this with the typical on-board means, to which undenyingly int() belongs to?
#!/usr/bin/perl my $i = 1.255; print int($i*100+.5)/100; print "\n";
Please register, that the same code will do as expected when using "1.355" as value for $i.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How to use the int-function?
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 Anonymous Monk on Jan 03, 2011 at 16:25 UTC | |
by ruzam (Curate) on Jan 03, 2011 at 19:30 UTC | |
|
Re^3: How to use the int-function?
by Anonymous Monk on Jan 04, 2011 at 08:48 UTC | |
by kennethk (Abbot) on Jan 04, 2011 at 18:14 UTC |