Re: Quick rounding to nearest integer

2001-05-18 Thread Timothy Kimball
Jos Boumans said: : try to take a look at the 'floor' and 'ceil' in the posix module : : they will do exactly what you want! Not quite. They don't round, they truncate: round floor ceil 10.010 10 10 10.210 10 11 10.711 10 11 Now Craig said: : I have an nu

Re: Quick rounding to nearest integer

2001-05-18 Thread Jos Boumans
try to take a look at the 'floor' and 'ceil' in the posix module they will do exactly what you want! POSIX qw(ceil floor) perldoc posix Kind regards, Jos Boumans Craig Moynes/Markham/IBM wrote: > I looked through my book (perl nutshell) and PP has not arrived yet, so I > will ask here. > >

RE: Quick rounding to nearest integer

2001-05-18 Thread Jeff Pinyan
On May 18, John Storms said: >Not the best code, but it works fine. > ># roundup(,[]); ># returns a truncated and rounded up value. >sub roundup { >my($i); for($i=0;$i$char = substr($num,$i,1); >$next = substr($num,$i+1,1); Rounding numbers shouldn't be a

Re: Quick rounding to nearest integer

2001-05-18 Thread Jeff Pinyan
On May 18, Craig Moynes/Markham/IBM said: >I looked through my book (perl nutshell) and PP has not arrived yet, so I >will ask here. > >I have an number that needs to be rounded to the nearest whole number. >This is my solution: Timothy Kimball has a good solution, but I have a generalization:

Re: Quick rounding to nearest integer

2001-05-18 Thread Timothy Kimball
: Is there an easier way (or more efficent). This is more a curiosity than : anything else. Easy and efficient, as long as $archives_needed is always positive: $archives_needed = int($archives_needed + 0.5); Otherwise, if $archived_needed can be negative: $archives_needed = int($archives_nee

Re: Quick rounding to nearest integer

2001-05-18 Thread Kevin Meltzer
perldoc -f sprintf $archives_needed = sprintf "%.0f", $archives_needed; Cheers, Kevin On Fri, May 18, 2001 at 09:05:37AM -0400, Craig Moynes/Markham/IBM ([EMAIL PROTECTED]) spew-ed forth: > I looked through my book (perl nutshell) and PP has not arrived yet, so I > will ask here. > > I have a