in reply to Bit string manipulation made easy with Bit::Manip

Steve:

You have set, on, & off, should you also have clr?

James

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

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

Replies are listed 'Best First'.
Re^2: Bit string manipulation made easy with Bit::Manip
by soonix (Chancellor) on Jan 30, 2017 at 19:08 UTC
    Hmm, … but you could just do $data = 0; or did I understand you wrong?
Re^2: Bit string manipulation made easy with Bit::Manip
by stevieb (Canon) on Jan 30, 2017 at 19:50 UTC

    Do you mean clr on a single bit? ie. do you mean 'unset' (or zero) it?, or do you mean the entire byte? I can definitely add that for completeness, but as soonix stated, $data = 0; will do it too.

      My thought was that James wanted _clr is to _set as _off is to _on... But that's not really necessary, since all you need to do is _set($data, $lsb, $bits, 0).

        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...