Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: ba0ef10b1defa5ec91d8ed803f9befceda1a1a58
Ticket: 1663473fffffffffffffffffffffffffffffffff
binary scan seems to be losing bits
User & Date: lvirden on 2007-02-19 13:35:59
Changes

  1. assignee changed to: "dkf"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    From the man page for binary scan:
    
         b    The data is turned into a string of count binary digits in
              low-to-high order represented as a sequence of ``1'' and
              ``0'' characters.  The data bytes are scanned in first to
              last order with the bits being taken in low-to-high order
              within each byte.  Any extra bits in the last byte are
              ignored.  If count is *, then all of the remaining bits in
              string will be scanned.  If count is omitted, then one bit
              will be scanned.  For example,
                   binary scan \x07\x87\x05 b5b* var1 var2
              will return 2 with 11100 stored in var1 and 1110000110100000
              stored in var2.
    
    
    Perhaps I don't understand the meaning of the phrase "remaining bits in string".
    
    It seems, to me, that this is a 24 bit string:
     % puts [string length  \x07\x87\x05 ]
     3
    and as far as I know, on a sparc solaris machine, 3 bytes, times 8 bits per byte, should equal 24 bits.
    
     % binary scan \x07\x87\x05 b5b* var1 var2
    2
     % puts $var1
    11100
     % puts $var2
    1110000110100000
    % puts [string length $var1$var2]
    21
    
    Notice that 3 bits are missing. They are 000 from the first byte of the 3 bytes...
    
  4. foundin changed to: "obsolete: 8.5a6"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "lvirden"
  10. subsystem changed to: "16. Commands A-H"
  11. title changed to: "binary scan seems to be losing bits"
  12. type changed to: "Bug"