From: SourceForge.net <no...@so...> - 2007-02-19 23:59:23
|
Bugs item #1663473, was opened at 2007-02-19 05:35 Message generated for change (Comment added) made by hobbs You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=1663473&group_id=10894 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: 12. ByteArray Object Group: development: 8.5a6 >Status: Closed >Resolution: Invalid Priority: 5 Private: No Submitted By: Larry W. Virden (lvirden) Assigned to: Jeffrey Hobbs (hobbs) Summary: binary scan seems to be losing bits Initial Comment: >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... ---------------------------------------------------------------------- >Comment By: Jeffrey Hobbs (hobbs) Date: 2007-02-19 15:59 Message: Logged In: YES user_id=72656 Originator: NO Using tkcon: (Tcl) 51 % binary scan \x07\x87\x05 b5b* var1 var2 2 (Tcl) 52 % binary scan \x07\x87\x05 b* var3 1 (Tcl) 53 % dump var var* set ::var1 11100 set ::var2 1110000110100000 set ::var3 111000001110000110100000 You see that the missing 000 would be the first part of var2 - IOW, extraneous bits. I don't see a bug here. The values are correct, it is just that Tcl does format with all the preceding 0s. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=1663473&group_id=10894 |