Can someone explain the difference between the "OR" statements and when to use which one
| vs ||
[expr if($f1 == $f2 || $f3 == $f4);]
[expr if($f1 == $f2 | $f3 == $f4);]
Math | vs ||
Can someone explain the difference between the "OR" statements and when to use which one
| vs ||
[expr if($f1 == $f2 || $f3 == $f4);]
[expr if($f1 == $f2 | $f3 == $f4);]
@mrsstaceyseigle "||" is a logical operator..... so its output is "true" or "false"...... 1 or 0.
"|" is a bitwise operator...... that you might never need to use....?
"Bitwise operators: "&" and "|" perform "and" and "or" on each bit of the inputs considered as binary numbers. ">>" and "<<" perform left and right signed bit shifts."
See [otherbinops-help] for examples of how they work.
David.
"|" converts its inputs to integers (which should be 32-bits in length on any of the platforms on which Pd runs), performs the bitwise OR on the bits of those integers, then converts the result back to a float for output.
In other words, you are operating on the inputs as if they were integers, even though all numbers in Pd are floats. The vast majority of the time this turns out to be exactly what the user wants to do. (Most of the common bitmath tasks are operations on integers.)
An exception is the case where the user wants to operate directly on the bits of the IEEE 754 binary representation of the inputs. You can do that in a Pd external written in C, but AFAICT not from with a Pd patch. But even in C this is prone to error and undefined behavior, so it's probably good that you can't do that directly in Pd.
Oops! Looks like something went wrong!