Just starting out? Need help? Post your questions and find answers here.
TimmyTom
User
Posts: 36 Joined: Mon Aug 18, 2003 8:32 am
Post
by TimmyTom » Mon Feb 21, 2005 12:48 am
Isn't a byte supposed to be 0 to 255?
I am trying to write an app that searches in memory of a process (this all works just fine).. but when i search for '100' in memory (64 in hex) Purebasic tells me it's -56 ..
I am mystified here
Tim
sverson
Enthusiast
Posts: 286 Joined: Sun Jul 04, 2004 12:15 pm
Location: Germany
Post
by sverson » Mon Feb 21, 2005 1:18 am
Unfortunately PB offers just signed integers
viewtopic.php?t=6896&highlight=unsigned+integer
Byte .b 1 Byte in memory -128 to +127
Word .w 2 Byte in memory -32768 to +32767
Long .l 4 Byte in memory -2147483648 to +2147483647
You can treat your variables as unsigned using & (AND) $FF /$FFFF / $FFFFFFFF:
Code: Select all
sVar.b = $FF
Debug sVar
Debug sVar&$FF
If sVar>200
Debug "unsigned"
Else
Debug "signed"
EndIf
If sVar&$FF>200
Debug "unsigned"
Else
Debug "signed"
EndIf
sVar.b = -100
Debug sVar
Debug sVar&$FF
sVar.b = 200
Debug sVar
Debug sVar&$FF
sverson
blueznl
PureBasic Expert
Posts: 6172 Joined: Sat May 17, 2003 11:31 am
Contact:
Post
by blueznl » Mon Feb 21, 2005 4:36 am
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide
right here ... )