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

Re^4: Bit string manipulation made easy with Bit::Manip

by jmlynesjr (Hermit)
on Jan 31, 2017 at 21:48 UTC ( #1180723=note: print w/replies, xml ) Need Help??


in reply to Re^3: Bit string manipulation made easy with Bit::Manip
in thread Bit string manipulation made easy with Bit::Manip

Bingo!

While not necessary, it seems that clr would complete the API. As an old assembly coder, I think in terms of setting, clearing and flipping/toggling bits.

As a minor nit pick... Setting a bit "on" or "off" doesn't tell you if the hardware is turning a device "on" or "off". Depends on how the designer set up the hardware. Active high? Active low? Could be either.

James

There's never enough time to do it right, but always enough time to do it over...

  • Comment on Re^4: Bit string manipulation made easy with Bit::Manip

Replies are listed 'Best First'.
Re^5: Bit string manipulation made easy with Bit::Manip
by stevieb (Abbot) on Feb 01, 2017 at 20:21 UTC

    I have added in a new function, bit_clr(), which will clear a range of bits: bit_clr($int, $lsb, $nbits);. Here's a small sample of my test file. This functionality will be available in the next release. Thanks for the suggestion!

    Sample part of test file:

    is bit_bin(bit_clr(255, 0, 8)), '0', "255, 0, 8 ok"; is bit_bin(bit_clr(255, 0, 2)), '11111100', "255, 0, 2 ok"; is bit_bin(bit_clr(255, 0, 3)), '11111000', "255, 0, 3 ok"; is bit_bin(bit_clr(255, 0, 4)), '11110000', "255, 0, 4 ok"; is bit_bin(bit_clr(255, 3, 1)), '11110111', "255, 3, 1 ok"; is bit_bin(bit_clr(255, 3, 2)), '11100111', "255, 3, 2 ok"; is bit_bin(bit_clr(255, 3, 3)), '11000111', "255, 3, 3 ok"; is bit_bin(bit_clr(255, 7, 1)), '1111111', "255, 7, 1 ok";

      My work is done here! LOL

      James

      There's never enough time to do it right, but always enough time to do it over...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1180723]
help
Chatterbox?
and snow settles gently...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (1)
As of 2018-08-17 01:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:









    Results (174 votes). Check out past polls.

    Notices?