Mail Archives: djgpp/1997/02/17/19:55:17
> I was assuming that the upper byte would be zeroed in the conversion (unsigned)Ch.
> I.E.
> char : 10110011 -----> unsigned : 0000000010110011
>
> Is this assumption wrong and the upper byte could be anything?
i didn't understand most of this as it was in c++ but that part above is
wrong.
char is by default signed, so having the higher bit set as 1 like that will
be treated as a negative number. then you try to convert a negative number
into an unsigned short. actually i'm not sure what that will do, it might
append leading 1's instead of 0's as you expect, i always avoid those sort
of problems by ensuring i have an unsigned char in the first place before
conversion :)
regards,
nik
--
Graham Tootell
nikki AT gameboutique DOT com
- Raw text -