Archive: Logic functions


14th October 2004 13:09 UTC

Logic functions
Every once in a while i get the need to use logic functions in avs, and i can't figure out how to do it with if() above() equal() and below(). I'm sure there are ways to do it but i feel it would save a lot of time and speed if there was logic functions in avs. In case you don't know what logic funtions are, keep reading. I'm not sure if band() bor() bnot() is what i'm looking for but this is what i'm talking about:

The and(var1,var2) function equals 1 when var1 AND var 2 are nonzero, 0 otherwise.

The or(var1,var2) function equals 1 when either var1 OR var 2 are nonzero, 0 otherwise

And the not(var1) function returns 0 if var1 is nonzero and 1 if var1 equals 0.

I don't know why i'm suggesting this, avs isn't going anywhere.


14th October 2004 16:57 UTC

band, bor, bnot are what you are looking for :)

band(a,b) returns 1 if a AND b are not zero. Otherwise, it returns 0.
bor(a,b) returns 1 if a OR b are not equal to 0. Otherwise it returns 0.
bnot(a) returns 1 if a is equal to 0. Otherwise it returns 0.

Note: logical 1 in these cases is anything other than 0. so:

bnot(22) == 0
bor(0,-10) == 1
band (1234123,12341234) == 1


15th October 2004 04:35 UTC

cool, thanks.


15th October 2004 22:40 UTC

Err this is all explained the evallib help. Click "expression help" in any of the avs components with code.


16th October 2004 06:38 UTC

yeah, but their explained as boolean functions, wtf is a boolean function?


16th October 2004 10:06 UTC

'Boolean' is a word to describe something which can only have two states... typically 1 and 0 in the computer world (the only world you should care about.) By 'boolean function' it just means a function which will return a 1 or 0... so you can use it in if statements ect..


16th October 2004 21:20 UTC

Originally posted by Mr_Nudge
yeah, but their explained as boolean functions, wtf is a boolean function?
And the reason why it is called exactly boolean is because the person who invented the boole-algebra was called Boole :)

17th October 2004 09:24 UTC

And i heard Boole played a lot of pool, which has only two statements: Either your balls are on the table or in the sack.




err... wtf?


17th October 2004 09:40 UTC

i get it now :)