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 (Canon) 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...