Is it possible to perform bitwise AND, OR and XOR operations in mel?
thnx
Is it possible to perform bitwise AND, OR and XOR operations in mel?
thnx
Do yu mean
|| or
&& and
Example 1
if ((time > 5) && (time < 10))
Ball.scaleZ = time;
Those are logical operators, hes talking about bitwise which are:
| bitewise or
& bitwise and
if( $blah & &blah2 )
....
What's the difference?.. that's I understand the logic of the example I showed .. how would yours work?
Logical operands test the true/false status of variables, Bitwise operands test the true/false status of individual bits within a variable (eg: check to see if they're set to 1 or 0).
Examples (Jscript):
// Example 1 - Bitwise AND
// See if number's 3rd bit (from right) is set
// (test against the value of the 3rd bit (4))
var number = 13; (00001101 in binary)
if ( number & 4 ) {
// yep (result: 00000100)
Ball.scaleZ = number;
} else {
// nope (result: 00000000)
Ball.scaleZ = 0;
}
// Example 2 - Bitwise OR
// See if either variable has set bits
var n1 = 32; (00100000 in binary)
var n2 = 13; (00001101 in binary)
var result = n1 | n2; (result: 00101101)
Ball.scaleZ = ( result == n2 + n1 ? result : 0 );
// Example 3 - Bitwise XOR
// Find unique bits between variables
var n1 = 13; (00001101 in binary)
var n2 = 4; (00000100 in binary)
var result = n1 ^ n2; (result: 00001001)
Ball.scaleZ = ( result ? result : 0 );
Cool.. didn't know MEL could do that ![]()
I never said MEL could do that nor do I know if MEL is capable.
All I did was explain bitwise operands using Jscript (Javascript).
Oh yeah.. the code you showed looked like MEL but isn't.. too bad.. I still think in terms of Perl alot but alas MEL isn't Perl is it ![]()