Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^5: Operate with bits

by GrandFather (Sage)
on Mar 12, 2020 at 07:29 UTC ( #11114159=note: print w/replies, xml ) Need Help??


in reply to Re^4: Operate with bits
in thread Operate with bits

Maybe because syedasadali95 is actually dealing with hex digits (nibbles), not with bits as assumed by my post and stated by every one of syedasadali95's posts up until the reply to soonix.

Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Replies are listed 'Best First'.
Re^6: Operate with bits
by AnomalousMonk (Bishop) on Mar 12, 2020 at 08:07 UTC

    Even so:

    c:\@Work\Perl\monks>perl -wMstrict -le "LINE: for my $line ( 'tag:0x3bb5044d addr:0x1009db0 qospri:40 len:0x40', 'tag:0x3bb5043d addr:0x1009d40 qospri:30 len:0x30', 'tag:0x3bb5044d addr:0xb0 qospri:40 len:0x40', 'tag:0x3bb5043d addr:0x40 qospri:30 len:0x30', 'tag:0x3bb5044d qospri:40 len:0x40', 'tag:0x3bb5043d qospri:30 len:0x30', ) { my $got_addr = my ($hex_str) = $line =~ m{ addr:0x ([[:xdigit:]]+) }xms; ;; next LINE if not $got_addr; ;; my $bit_6_set = 0x40 & hex $hex_str; ;; printf qq{bit 6 %7s in %9s of '$line' \n}, $bit_6_set ? 'set' : 'not set', qq{'$hex_str'} ; } " bit 6 not set in '1009db0' of 'tag:0x3bb5044d addr:0x1009db0 qospri:40 + len:0x40' bit 6 set in '1009d40' of 'tag:0x3bb5043d addr:0x1009d40 qospri:30 + len:0x30' bit 6 not set in 'b0' of 'tag:0x3bb5044d addr:0xb0 qospri:40 len: +0x40' bit 6 set in '40' of 'tag:0x3bb5043d addr:0x40 qospri:30 len: +0x30'


    Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2020-07-06 20:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?