Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Check even numbers?

by GrandFather (Saint)
on Aug 06, 2006 at 22:12 UTC ( [id://565871]=note: print w/replies, xml ) Need Help??


in reply to Check even numbers?

Check the least significant bit. It is set for odd numbers:

print "$_ is " . ($_ & 1 ? "odd" : "even") . "\n" for 0..3;

Prints:

0 is even 1 is odd 2 is even 3 is odd

DWIM is Perl's answer to Gödel

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://565871]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2025-01-16 15:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (54 votes). Check out past polls.