Page 1 of 1

Reading unsigned bytes from file

Posted: Wed Jun 04, 2003 8:32 am
by Gantry
Hi all!

I am sure this is a simple one. I want to read one or more bytes from a file. I want to use the unsigned value of each byte in calculations. I don't want negative values. Anyone?

regards,

gantry

Posted: Wed Jun 04, 2003 9:05 am
by Inner
if I remember correctly

value & 255 ; I think

Posted: Wed Jun 04, 2003 10:13 am
by freak
yep, but you must store the result of 'value & 255' i something like WORD or LONG.
If you store it in a BYTE again, you'll get just the same signed thing :wink:

Timo

Posted: Wed Jun 04, 2003 2:20 pm
by Gantry
So obvious, and yet I couldn't figure it out! :oops:

Thank you!

/Gantry