Re: Signed and Unsigned integers in Tcl
- From: Andreas Leitgeb <avl@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: 15 Sep 2006 10:15:41 GMT
Sektor van Skijlen <ethouris@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Hmm...
% set value -32768; format %08x [expr {$value >> 4}]
fffff800
% set value 0xffff8000; format %08x [expr {$value >> 4}]
0ffff800
That's indeed strange, especially as it also happens in Tcl8.4 (.9 here)
It appears to be a "feature" more than a bug, though:
% expr 0xfffff800
4294965248
% set value 4294965248; format %08x [expr {$value >> 4}]
0fffff80
For Tcl8.5 this would be the expected behaviour, anyway, since
integers do no longer wrap around there at all.
So, for example, to "retype" the integer value from signed to unsigned should
be accomplished with:
set value [format %x $value]
You'd also have to prepend the 0x, of course, but yes.
.
- Follow-Ups:
- Re: Signed and Unsigned integers in Tcl
- From: Pat Thoyts
- Re: Signed and Unsigned integers in Tcl
- References:
- Signed and Unsigned integers in Tcl
- From: Sektor van Skijlen
- Signed and Unsigned integers in Tcl
- Prev by Date: Re: Tcl_GetChannelHandle( fileChannel, TCL_READABLE, (ClientData *) &fd ) ...
- Next by Date: Re: Regular expresion, one more time!
- Previous by thread: Re: Signed and Unsigned integers in Tcl
- Next by thread: Re: Signed and Unsigned integers in Tcl
- Index(es):
Relevant Pages
|