RE: Round number

2001-05-31 Thread Lee Goddard
Have you seen the docs? If yes, please ignore; otherwise: perldoc -q round:- Does Perl have a round() function? What about ceil() and floor()? Trig functions? Remember that int() merely truncates toward 0. For rounding to a certain number of digits, sprintf() or pri

RE: Round number

2001-05-31 Thread Cornish, Merrill
If you want to simply round to the nearest integer, then do $number = int($number + 0.5) Therefore, n.4999... and below become n while n.5... and above become n+1. The only problem with this simple fix is that it is biased because slightly more numbers will rounded up to the nex

Re: Round number

2001-05-31 Thread Morbus Iff
>I'm getting some information from my database and after some mathematical >operations i get a decimal number and i would like to round it...how can i >do that? A lot of people will say "int! int!", but you can find a more "powerful" routine called "round" at the URL below. It allows you to c