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

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";

Replies are listed 'Best First'.
Re^6: Bit string manipulation made easy with Bit::Manip
by jmlynesjr (Deacon) on Feb 02, 2017 at 15:38 UTC

    My work is done here! LOL

    James

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