Version 2 of Bit manipulations

Updated 2005-05-27 14:26:55

if 0 {I've come across skepticism about Tcl's facility for bit manipulation one too many times. While RS's usual tour de forces such as "Playing with bitstrings" and "Big bitstring operations" show how good Tcl can be at bit manipulation, this page has a far more limited ambition: simply to help hardware- or C-oriented developers to feel comfortable working on low-level data in a higher-level language.}

      # Let's experiment:  one model for "low-level data" is a byte array, or
      # byte sequence.  A sequence of eight-bit values is often the manifestation
      # of information received from a physical device through a serial port, or
      # from a remote host through a network connection.  Start, then, with
      # sample data:
  set sample "\