Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^3: Bitwise AND with large numbers

by Eliya (Vicar)
on Apr 16, 2012 at 17:12 UTC ( #965361=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use Math::BigInt;
    
    ...
    my $hexstring = Math::BigInt->new('0x40000000000000000000000000000000'
    +); 
    my $mask = (Math::BigInt->new('0x80000000000000000000000000000000') >>
    + $switchPortNumber);
    my $result = ($hexstring & $mask) > 0;
    
  2. or download this
    my $bitstring = unpack('B*', pack('H*', '40000000000000000000000000000
    +000'));
    my $result = substr($bitstring, $switchPortNumber, 1) eq '1';
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2014-09-18 04:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (108 votes), past polls