例如
1.2 = 1 1.7 = 2
解决方法
perldoc -q round
Does Perl have a round() function? What about ceil() and floor()?
Trig functions?Remember that 07001 merely truncates toward
0
. For rounding to a certain number of digits,07002 or 07003 is usually the easiest
route.06000
The 07004 module (part of the standard Perl distribution) implements
ceil()
,floor()
,and a number of other mathematical and trigonometric
functions.06001
In 5.000 to 5.003 perls,trigonometry was done in the 07005
module. With 5.004,the 07006 module (part of the standard Perl
distribution) implements the trigonometric functions. Internally it
uses the 07005 module and some functions can break out from the
real axis into the complex plane,for example the inverse sine of 2.Rounding in financial applications can have serIoUs implications,and
the rounding method used should be specified precisely. In these
cases,it probably pays not to trust whichever system rounding is being
used by Perl,but to instead implement the rounding function you need
yourself.To see why,notice how you’ll still have an issue on half-way-point
alternation:06002
Don’t blame Perl. It’s the same as in C. IEEE says we have to do
this. Perl numbers whose absolute values are integers under2**31
(on 32 bit machines) will work pretty much like mathematical integers. Other numbers are not guaranteed.