Artifacts Associated With Ticket 1663473fffffffff
Ticket change [ba0ef10b1d] (rid 129254) by lvirden on 2007-02-19 13:35:59:
- assignee initialized to: "dkf"
- cmimetype initialized to: "text/plain"
- comment initialized 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... - foundin initialized to: "obsolete: 8.5a6"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "lvirden"
- subsystem initialized to: "16. Commands A-H"
- title initialized to: "binary scan seems to be losing bits"
- type initialized to: "Bug"
Ticket change [f4502147eb] (rid 129889) by dkf on 2007-02-20 05:31:04:
- assignee changed to: "hobbs"
- subsystem changed to: "12. ByteArray Object"
Ticket change [60a4d92863] (rid 116034) by hobbs on 2007-02-20 06:59:23:
- closedate changed to: "2007-02-19T23:59:23"
- closer changed to: "hobbs"
- icomment:
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.
- login: "hobbs"
- mimetype: "text/plain"
- resolution changed to: "Invalid"
- status changed to: "Closed"
- username: "hobbs"
Ticket change [69781b949e] (rid 103260) by lvirden on 2007-02-20 18:30:58:
- icomment:
Logged In: YES user_id=15949 Originator: YES binary scan \xff\xff\xff var3 var4 shouldn't be any leading zeros here, right? however, puts $var3 11111 which is what I would expect puts $var4 1111111111111111 string length $var4 16 Still only seeing 21 of the 24 bits. Shouldn't there be 19 bits here?
- login: "lvirden"
- mimetype: "text/plain"
- resolution changed to: "Rejected"
- username: "lvirden"
- icomment:
Ticket change [d588692212] (rid 123640) by msofer on 2007-02-20 20:09:20:
- icomment:
Logged In: YES user_id=148712 Originator: NO The way I understand the last example binary scan \xff\xff\xff b5b* var3 var4 according to the docs is: (1) first read 5 bits, ie, the first 5 bits of one byte. The 5 bits are put into var3, the remaining 3 bits are discarded ("Any extra bits in the last byte are ignored."). The first byte is now done with. (2) now read all the rest. A slightly different experiment seems to confirm this interpretation (a final answer requires source diving, which I may do later): % binary scan \xff\xff\xff b8b* var3 var4 2 % string length $var3 8 % string length $var4 16 % binary scan \xff\xff\xff b9b* var3 var4 2 % string length $var3 9 % string length $var4 8 I do confess that this interpretation has been arrived at *after* seeing the example; the docs may need to be improved? - login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Ticket change [925d31ac25] (rid 120752) by lvirden on 2007-02-20 20:28:45:
- icomment:
Logged In: YES user_id=15949 Originator: YES updated docs would seem to be useful. This does mean that one cannot scan a byte into two or more variables. One has to scan the byte in, then split the string up via normal string functions. That's too bad - it would have been nice to have had a format that would allow the person to split the byte up into several pieces - getting at the various status bits of a control register or whatever.
- login: "lvirden"
- mimetype: "text/plain"
- username: "lvirden"
- icomment:
Ticket change [17bb5ed186] (rid 122543) by dkf on 2007-02-20 21:40:27:
- icomment:
Logged In: YES user_id=79902 Originator: NO The problem is that reading at the bit level across multiple variables would make the code to do bulk uses of [binary scan] much harder since you'd have to allow for someone reading one bit and then 100kB of 32-bit words, all offset by one bit, even though this is a vanishingly rare case.
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment: