Is Boolean FALSE?

New to FreeBASIC? Post your questions here.
vdecampo
Posts: 2982
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Postby vdecampo » Sep 22, 2009 19:28

I just created a boolean NOT operator.

Code: Select all

#Define bNOT(x)     IIF ((x)=0,1,0)

Dim as Integer test = 0

If bNOT(test) then
   Print "Test must be zero"
else
   Print "Test is non-zero"
endif


-Vince
Last edited by vdecampo on Sep 22, 2009 21:57, edited 1 time in total.
counting_pine
Site Admin
Posts: 6169
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Postby counting_pine » Sep 22, 2009 20:19

@voodooattack: watch out for your '=' operator.
@vdecampo: if you're going to make a bNOT macro, just make it ((x)=0). That will avoid operator precedence issues, and also allow "NOT bNOT(x)" to work!
vdecampo
Posts: 2982
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Postby vdecampo » Sep 22, 2009 21:56

@counting_pine

You are absolutely right! That is how I have it in my code library. I wrote the example from memory and forgot that. :o

-Vince
voodooattack
Posts: 605
Joined: Feb 18, 2006 13:30
Location: Alexandria / Egypt
Contact:

Postby voodooattack » Sep 22, 2009 23:18

counting_pine wrote:@voodooattack: watch out for your '=' operator.


Thanks, I see, fixed.

Return to “Beginners”

Who is online

Users browsing this forum: fxm and 2 guests