ObjectScript Reference
$BITLOGIC


$BITLOGIC(bitstring_expression,length)
A logical expression consisting of one or more bitstring variables and the logical operators &, , ^, and ~. A bitstring can be specified as a local variable, a processprivate global, a global, an object property, or the constant "". The null string ("") has a bitstring length of 0. A bitstring cannot be specified using a function (such as 

// Set a to [1,1] SET $BIT(a,1) = 1 SET $BIT(a,2) = 1 // Set b to [0,1] SET $BIT(b,1) = 0 SET $BIT(b,2) = 1 WRITE !,"bitstring a=",$BIT(a,1),$BIT(a,2) WRITE !,"bitstring b=",$BIT(b,1),$BIT(b,2) SET c = $BITLOGIC(~b) WRITE !,"The one's complement of b=",$BIT(c,1),$BIT(c,2) // Find the intersection (AND) of a and b SET c = $BITLOGIC(a&b) // c should be [0,1] WRITE !,"The AND of a and b=",$BIT(c,1),$BIT(c,2) SET c = $BITLOGIC(a&~b) // c should be [1,0] WRITE !,"The AND of a and ~b=",$BIT(c,1),$BIT(c,2) // Find the union (OR) of a and b SET c = $BITLOGIC(ab) // c should be [1,1] WRITE !,"The OR of a and b=",$BIT(c,1),$BIT(c,2) SET c = $BITLOGIC(a^b) // c should be [1,0] WRITE !,"The XOR of a and b=",$BIT(c,1),$BIT(c,2) QUIT
// Set a to [1,1,1] SET $BIT(a,1) = 1 SET $BIT(a,2) = 1 SET $BIT(a,3) = 1 WRITE !,"bitstring a=",$BIT(a,1),$BIT(a,2),$BIT(a,3) SET c = $BITLOGIC(a,2) WRITE !," a (length 2)=" WRITE $BIT(c,1),$BIT(c,2),$BIT(c,3),$BIT(c,4) SET c = $BITLOGIC(~a,2) WRITE !,"~a (length 2)=" WRITE $BIT(c,1),$BIT(c,2),$BIT(c,3),$BIT(c,4)
Content for this page loaded from RCOS_fbitlogic.xml (file updated 20181212 22:52:49)
