From:                   "Zielfelder, Robert" 
<[EMAIL PROTECTED]>
> I am trying to write a script that at one point needs to look at a
> number and divide it by two.  The results must always be an integer,
> but the numerator can potentially be an odd number.  What I want to do
> is if the numerator is odd, increment it to the next highest even
> number.  Is there a function in PERL that will allow me to test
> weather or not an integer is odd or even so that I can increment the
> number before I do the division?

TIMTOWTDI

$num++ if $num % 2;
        # if modulo 2 is 1

$num++ if $num & 1;
        # if the lowest bit is set

....

Jenda=========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz 
==========
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


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

Reply via email to