Reading unsigned bytes from file

Just starting out? Need help? Post your questions and find answers here.
Gantry
User
User
Posts: 20
Joined: Tue Jun 03, 2003 6:24 am
Location: Sweden

Reading unsigned bytes from file

Post 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
User avatar
Inner
PureBasic Expert
PureBasic Expert
Posts: 714
Joined: Fri Apr 25, 2003 4:47 pm
Location: New Zealand

Post by Inner »

if I remember correctly

value & 255 ; I think
freak
PureBasic Team
PureBasic Team
Posts: 5948
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post 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
quidquid Latine dictum sit altum videtur
Gantry
User
User
Posts: 20
Joined: Tue Jun 03, 2003 6:24 am
Location: Sweden

Post by Gantry »

So obvious, and yet I couldn't figure it out! :oops:

Thank you!

/Gantry
Post Reply