On Wed, 2002-04-17 at 13:46, drieux wrote:
> 
> On Wednesday, April 17, 2002, at 10:12 , bob ackerman wrote:
> 
> > for integers:
> > (add one) divide by 2.
> > $rndup = ($var+1)/2;
> 
> that would give you a float....
> 
>       print "half of $_ rounded up is " . ( ($_ + 1) / 2)  . "\n"
>               foreach (@ARGV) ;
> 
>       perl /tmp/drieux/roundup.pl 1 2 3 4 5 6
>       half of 1 rounded up is 1
>       half of 2 rounded up is 1.5
>       half of 3 rounded up is 2
>       half of 4 rounded up is 2.5
>       half of 5 rounded up is 3
>       half of 6 rounded up is 3.5
> 
> 
> but:
> 
>       print "half of $_ rounded up is " . int(( $_ / 2) + 0.5 ) . "\n"
>               foreach (@ARGV) ;
> 
> will give you:
> 
>       perl /tmp/drieux/roundup.pl 1 2 3 4 5 6
>       half of 1 rounded up is 1
>       half of 2 rounded up is 1
>       half of 3 rounded up is 2
>       half of 4 rounded up is 2
>       half of 5 rounded up is 3
>       half of 6 rounded up is 3
>       
> ciao
> drieux
> 

I think there may have been an implied "use integer;" pragma in what he
said ("for integers:").  Of course, I could be wrong.
 
-- 
Today is Boomtime the 34th day of Discord in the YOLD 3168
Keep the Lasagna flying!

Missile Address: 33:48:3.521N  84:23:34.786W


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to