Archive: Boolean Operators I need to break them.


25th November 2005 09:34 UTC

Boolean Operators I need to break them.
I was a bit frightend to revive this old thread, because there already was 2 resurrections made to it and UnConeD bitched both times ;)

Anyway, my problem is as follows:
Before the & operator was fixed, i made a bunch of presets that used that operator with some cool (although random) results. Now that i look back into the presets, they don't work because of the fixed operator :cry:

Now i need something that i can replace the fixed & operator with that does the same thing the broken & operator did.

Don't bother posting loads of mathematical explanations, just gimme something i can use straight in AVS.

Im also pretty sure there's lots of other people who would find use for this.


25th November 2005 12:10 UTC

try floor() or ceil() they work in some cases (if you used & to make stuff into integers). but i dont think there is anything that does the same dogdy function as the old &


25th November 2005 13:36 UTC

What operations do you need?


26th November 2005 09:11 UTC

Nothing specific, i was just looking for a quick fix for this, most of the code is something along the lines x=x&sin(x)&y&y&y&y and other n00b shit like that. But i guess i have to fix my presets the "hard way" :hang:


26th November 2005 15:34 UTC

btw, i did a lot of stuff like that in the 'Mechanical Curvature' series of presets in my packs... they all seem to work fine here. :P

just tweak the existing &s and you may well get a comparable result.. although since i dont know what you are using it for its hard to give specifics.


26th November 2005 17:16 UTC

just install an older version of AVS :p


26th November 2005 17:50 UTC

I thought you were talking about boolean operations. I never get what the little help box means about the operators. Does convert values to interger mean ceil or somethings? Besides, by my understanding of things, | is completely useless, it would give the same as &...


26th November 2005 18:23 UTC

here is how it works:

the idea of a boolean values is that they are true or false, this lines up with a lot of avs functionality where 0 is false and non zero is true. e.g. below(a,b) returns 1 if a<b and 0 otherwise.

using 0 as false and non-zero as true, operators like band(a,b) and bor(a,b) do 'boolean and' and 'boolean or' operations, i.e. if a and b are true then return true for band, otherwise false and if a or b or both are true then return true for bor, otherwise false. these are boolean operators since they take boolean values as their parameters and produce a boolean result.

what & and | do is different but related. internally avs stores stuff as floating point numbers. even integers are stored as floats. a & b rounds the two operands a and b and converts them from float to integer representation (proably using floor, maybe doing a proper rounding) it then goes along each bit and does band to produce the resulting bit in the output:

e.g.
62&96 = ?



62: 00111110
96: 01100000
and: 00100000 = 32


each bit is compared to produce a bit in the result, so above only where two 1s line up is there a 1 in the output. | works the same way except that it does a boolean or operation, e.g.:

33|98 = ?


33: 00100001
98: 01100010
or: 01100011 = 99


its not exactly useful in avs though. most commonly i use these operators in programming languages to implement 'bit-flags', where you can use an integer like a small array of boolean values by using | and & to see which bits are turned on or off in the binary representation.

hope this helps clear it up a bit

26th November 2005 19:42 UTC

and integer means "whole number" [can you say that in english?] or "number without stuff behind the comma" :)
[just for clarity I don't think Jheriko pointed that out]
maybe one says integer in everyday english for that, so this post might be useless, but hey...


26th November 2005 21:22 UTC

Hehe...comma.

USA! USA! USA!

Anyway, that does clear things up for me...


26th November 2005 22:16 UTC

For the record, I've used & several times in my presets. I've used | less often, but I've still used it. There are some pretty cool effects possible that require this kind of binary math.

I'm unsure about what method these use to convert fractional values to integers, though. I would think, though, that they'd either use floor(n) or a rounding function roughly equivalent to floor(n+0.5). It sounds like the latter could be close to what the broken & may have done.


30th November 2005 22:33 UTC

I've only been doing AVS for about a year and a half, what was so broken about the & ?


1st December 2005 10:45 UTC

Quote:


.. you will never know :P


Nah, basically they didnt do the logic operations correctly and just did something similar to rounding the numbers.

Originally posted by JFASI
about a year and a half

1st December 2005 23:21 UTC

Oh, so they just sucked?


2nd December 2005 00:54 UTC

Apparently Tug found a way to make some use out of them.


2nd December 2005 01:46 UTC

Ah, that's good. But does he know how it was broken, or did he just find that they made arandom cool effect?