255 byte value...

BlitzMax Forums/BlitzMax Programming/255 byte value...

Haramanai(Posted 2006) [#1]
Local r:Byte = 0

If Not r = 255 Then Print "ok with not"
If r <> 255 Then Print "ok with <>"


Here I get only : ok with <>
Am I missing something or I am the only one with this result?


Suco-X(Posted 2006) [#2]
Hi
Local r:Byte = 0

If Not (r = 255) Then Print "ok with not"
If r <> 255 Then Print "ok with <>"


A bug? I don't know.
Mfg Suco


Suco-X(Posted 2006) [#3]
Ok, the B3D Version

Local r=0

If Not r = 255 Then Print "ok with not"
If r <> 255 Then Print "ok with <>"
WaitKey()

Runs fine.
"ok with not"
"ok with <>"
Mfg Suco


Dreamora(Posted 2006) [#4]
B3D isn't BM.
BM has seperated operators for bitoperation and boolean comparision and a "deeper" knowledge of data types then B3D had.
You operation does simply: not 0 ie not false -> true = 1

For what you want to do, you would need to use the bitwise XOR

Local r:Byte = 0

If ($FF ~ r) = 255 Then Print "ok with not"
If r <> 255 Then Print "ok with <>"


$FF ~ r reverts all bits of the byte


Haramanai(Posted 2006) [#5]
So I was missing something.
Still a bit confusing but it's good to know that the problem was me.


marksibly(Posted 2006) [#6]
Hi,

The operator precedence of 'Not' is different in BMX from B3D - use:

If Not (r = 255) Then Print "ok with not"