XOR ?

BlitzMax Forums/BlitzMax Programming/XOR ?

Filax(Posted 2005) [#1]
Hi

Do you know if bmax have XOR operator ?

Cheers


Dreamora(Posted 2005) [#2]
No it hasn't *see Language - Expression*


Filax(Posted 2005) [#3]
Hi :)

I have find

use : ~

example :

Print 100 ~ 10


Dreamora(Posted 2005) [#4]
~ is not ... not xor

a xor b = (a & ~b) | (~a & b)


Yan(Posted 2005) [#5]
Depends how you use it (XOR is a bitwise NOT/compliment)

b = 10
Print Bin$(b)

b :~ 2
Print Bin$(b)

b :~ 2
Print Bin$(b)

Print Bin$(~b)



Dreamora(Posted 2005) [#6]
hmm yeah you are right.
Sorry for wrong posting above.

Somehow missed the 2nd appearance of it in the help ...


Filax(Posted 2005) [#7]
So :) what is XOR :) ?

&~ ?

:~ ?

Can you clarify ?


marksibly(Posted 2005) [#8]
XOR is '~', eg:

Print $face ~ $babe

Bitwise invert is also '~', eg:

Print ~0

This is similar to the dual use of the minus sign.


Filax(Posted 2005) [#9]
Ok thanks mark :) for support ! :)


MrCredo(Posted 2005) [#10]
interesting...

mark, can you add new keywords for this??? i don't like such symbols - this is unreadable

~ -> XOR
| -> BOR (bitwise OR)
& -> BAND (bitwise AND)

please please please...


Filax(Posted 2005) [#11]
i agree !


Curtastic(Posted 2005) [#12]
I agree also.
I like how we use Mod instead of %%%%@$#%^%^
An how we can do x:Int,z:String, instead of x%,z$!#%@$%#


Gabriel(Posted 2005) [#13]
And it sure would save having to search the forum to find out why XOR doesn't work any more.


FlameDuck(Posted 2005) [#14]
mark, can you add new keywords for this???
Shouldn't it be BXOR tho? For consistence, XOR should be a conditional expression, ala. And Or and Not.


MrCredo(Posted 2005) [#15]
Flameduck:

x=~x
or
x=XOR x (if it available in some days..years)
is the same like
x=-x

but

x=y~z
is harder to read than
x=y XOR z

theoreticaly here should exist XOR and BXOR...

I don't understand why mark sibly do not add BAND, BOR and XOR-words... otherwise blitzmax looks so "unperfect"

r=(argb SHR 16) & 255

looks not so good

r=(argb SHR 16) BAND 255

is much better to read and understand

i think this was a mistake to replace AND to & and add a logic AND instead of this. The most time i forget this and i write each time AND..

more infos

http://en.wikipedia.org/wiki/Xor
http://en.wikipedia.org/wiki/Logical_disjunction
http://en.wikipedia.org/wiki/Logical_conjunction