Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Named Bits in a 32-bit integer

by hiseldl (Priest)
on Jul 31, 2002 at 18:40 UTC ( [id://186554]=note: print w/replies, xml ) Need Help??


in reply to Named Bits in a 32-bit integer

Assuming perl -P works on your system, you could define macros. Here is a short example:
#!/usr/bin/perl -P # set this to the bit masks #define ONE 1 #define TWO 2 #define THREE 3 #define FOUR 4 print "bitwise AND (ONE & FOUR)=", ONE & FOUR, "\n"; print "bitwise AND (ONE & THREE)=", ONE & THREE, "\n";
then running the script will produce:
$ ./script.pl
bitwise AND (ONE & FOUR)=0
bitwise AND (ONE & THREE)=1

If perl -P gives an error where it can't find cpp, you can probably copy the one from your gcc dist into a directory into your path.

--
hiseldl

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (1)
As of 2024-04-24 15:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found