How to reset a binary flag?

Just starting out? Need help? Post your questions and find answers here.
AZJIO
Addict
Addict
Posts: 2143
Joined: Sun May 14, 2017 1:48 am

How to reset a binary flag?

Post by AZJIO »

Is that the only way?

Code: Select all

x = 5
flag = 5
flag = (flag | x) ! x
Debug flag
User avatar
STARGÅTE
Addict
Addict
Posts: 2226
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: How to reset a binary flag?

Post by STARGÅTE »

I do it with Value And Not Flag

Code: Select all

Define Value.i = 6
Define Flag.i = 4

Debug Bin(Value)

Value & ~Flag

Debug Bin(Value)
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: How to reset a binary flag?

Post by Fred »

Yes that's the usual way to clear a flag
Post Reply