Search for Operator

Just starting out? Need help? Post your questions and find answers here.
Konne
Enthusiast
Enthusiast
Posts: 434
Joined: Thu May 12, 2005 9:15 pm

Search for Operator

Post by Konne »

Is there an Operator which Switches a 1 into a 0 and a 0 into a 1?

It should do the same than this code:

Code: Select all

      If Value=1
        Value=0
      Elseif Value=0
        Value=1      
      EndIf
Apart from that Mrs Lincoln, how was the show?
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Best available in PureBasic is a=1-a
BERESHEIT
jack
Addict
Addict
Posts: 1358
Joined: Fri Apr 25, 2003 11:10 pm

Post by jack »

Code: Select all

Value = Value XOr $FFFFFFFF
SCRJ
User
User
Posts: 93
Joined: Sun Jan 15, 2006 1:36 pm

Post by SCRJ »

Code: Select all


a = 1

a ! 1
Debug a
a ! 1
Debug a
User avatar
blueb
Addict
Addict
Posts: 1121
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Post by blueb »

Perhaps the Swap command is what you're looking for.
- It was too lonely at the top.

System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
naw
Enthusiast
Enthusiast
Posts: 573
Joined: Fri Apr 25, 2003 4:57 pm

Post by naw »

this would be the NOT operator, wouldnt it?
Ta - N
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

SCRJ wrote:

Code: Select all


a = 1

a ! 1
Debug a
a ! 1
Debug a
I think this methos is the best :wink:
I like logic, hence I dislike humans but love computers.
User avatar
einander
Enthusiast
Enthusiast
Posts: 744
Joined: Thu Jun 26, 2003 2:09 am
Location: Spain (Galicia)

Post by einander »

; some macros to switch values

Code: Select all

Macro Switch_1_0(n)  ;  switch between  1 and  0
    1-n
EndMacro

Macro Switch_0_Minus1(n)  ;  switch between -1 and 0
 n!-1
EndMacro

Macro Switch_1_2(n) ;switch  between 1 and 2
 3 - n
EndMacro
Froggerprogger
Enthusiast
Enthusiast
Posts: 423
Joined: Fri Apr 25, 2003 5:22 pm
Contact:

Post by Froggerprogger »

%1>>1+1*1/1-1!1|1&1<<$1=1
Post Reply