Re: binary scan and signed characters
- From: Aric Bills <aric.bills@xxxxxxxxx>
- Date: Sat, 30 Aug 2008 01:04:23 -0700 (PDT)
On 29 août, 23:15, Arjen Markus <arjen.mar...@xxxxxxxxxx> wrote:
Hello,
I stumbled upon the following:
I have a PGM file (one of the picture formats that Tk supports via the
image command) that I want
to read via Tcl (no Tk, so no image command). Part of the information
in that file is actually binary,
so I use [binary scan] to convert the bytes to numbers:
binary scan [string index $imageData $pos] value
To my surprise the numbers I get this way are signed, that is: they
range from -128 to 127.
My question: is this platform-dependent behaviour? Is it because the
underlying C run-time library
regards characters as signed? Or is Tcl using signed characters and
this behaviour is by design?
I can easily correct for this: set value [expr {256+$value}], but I
just wonder if this is a - to me -
new kind of platform-dependence.
Regards,
Arjen
I think the numbers are signed by design. If you want unsi
.
- References:
- binary scan and signed characters
- From: Arjen Markus
- binary scan and signed characters
- Prev by Date: Tcl 8.5 and special numbers
- Next by Date: Re: binary scan and signed characters
- Previous by thread: binary scan and signed characters
- Next by thread: Re: binary scan and signed characters
- Index(es):