Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / xor command?

Author
Message
watermark
21
Years of Service
User Offline
Joined: 25th Apr 2004
Location:
Posted: 25th Apr 2004 08:25
did a search and nothing came up...

is there an eqiviliant command to xor in db? Other basic languages offer this command (xor is must be one but not both)

ex.

if x=1 xor y=1 then print "hey"
medwayman
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: uk
Posted: 25th Apr 2004 10:22
Not that i've seen
i guess you would have to do something like



Based on Amiga PD game Squigs. Early shots: http://www.custardsoft.pwp.blueyonder.co.uk/images/03.png

Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 25th Apr 2004 11:38
There is, but if theres not a keyword, then I forget the symbol.

"eureka" - Archimedes
pizzaman
21
Years of Service
User Offline
Joined: 18th Feb 2004
Location: Gateshead, UK
Posted: 25th Apr 2004 18:43
have u tried xor cos im sure that xor works it just doesn't get highlighted by the ide
watermark
21
Years of Service
User Offline
Joined: 25th Apr 2004
Location:
Posted: 25th Apr 2004 22:36 Edited at: 25th Apr 2004 22:36
heh, of course I tried. I know it doesnt work in dbc. Thanks custard...kinda clutered tho, when it could be 1 line long. If anyone knows that symbol, plz post.
medwayman
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: uk
Posted: 25th Apr 2004 22:52


Based on what Phaelax said I messed a bit and found this worked

If x=1 <> y=1 then print “hey�



Based on Amiga PD game Squigs. Early shots: http://www.custardsoft.pwp.blueyonder.co.uk/images/03.png

JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 26th Apr 2004 04:24
~ (shift + then button next to [1]) is xor in java c(++) etc, and im sure in DBP, but i asked this question about it in DBC a whiel back and got the answer "doesnt exist".

Do you model? contact me: [email protected]
Lost in Thought
21
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 26th Apr 2004 08:16
I think ~~ is xor according to the help files.

"BITWISE LEFT SHIFT signified by the symbol << will shift all bits one space to the left. %0111 << 1 becomes %1110.
BITWISE RIGHT SHIFT signified by the symbol >> will shift all bits one space to the right. %0111 >> 1 becomes %0011.
BITWISE AND signified by the symbol && will AND all bits of one value with another. %1111 && %0011 becomes %0011.
BITWISE OR signified by the symbol || will OR all bits of one value with another. %1111 || %0011 becomes %1111.
BITWISE XOR signified by the symbol ~~ will XOR all bits of one value with another. %1111 ~~ %0011 becomes %1100.
BITWISE NOT signified by the symbol .. will NOT all bits of the right value. %1111 .. %1010 becomes %0101."

at least while using it bitwise.

"People don't fail ..... they stop trying." Specs. P4 2.8GHz 800 FSB | 512MB DDR333
GeForce FX 5200 AGP 256MB | Windows XP Pro Full
medwayman
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: uk
Posted: 26th Apr 2004 22:52
I think i’ve probably misunderstood what this command does. What Lost in Thought suggests works in pro but not in dbc.

Based on Amiga PD game Squigs. Early shots: http://www.custardsoft.pwp.blueyonder.co.uk/images/03.png

Lost in Thought
21
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 27th Apr 2004 01:14 Edited at: 27th Apr 2004 01:15
Yeah I don't use DBC I was just hoping it might be the same.

[Edit] But you can probably find it the same way I found it for DBP. Search for math in the help files of blue ide and it will show you all kinds of math operations.

"People don't fail ..... they stop trying." Specs. P4 2.8GHz 800 FSB | 512MB DDR333
GeForce FX 5200 AGP 256MB | Windows XP Pro Full
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 29th Jul 2004 05:10 Edited at: 29th Jul 2004 05:17
Ah-HA!

I found it!

I was actually searching around in the command list for another function I wanted, and discovered the following by accident;


& == Bit wise AND operation
1 & 3 returns 1
1 & 2 returns 0
2 & 3 returns 2

| == bit wise OR operatioin
1 | 2 returns 3
1 | 1 return 1

! == logical XOR operation
1 ! 0 returns 1
0 ! 0 returns 0
1 ! 1 returns 0
0 ! 1 returns 1
2 ! 1 returns 1 (based on bit zero I presume)

Any truly great code should be indisguishable from magic.

Login to post a reply

Server time is: 2025-05-25 16:07:59
Your offset time is: 2025-05-25 16:07:59