BOOL('1100110'b,'0101'b,'0110'b) /*returns '1001110'b */
In this example, the second argument is extended to '0101000'b. For bit 1, x is 1 and y is 0. Therefore, the resulting bit is the value m3or 1. For bit 2, x is 1 and y is 1, therefore the resulting bit is the value of m4 or 0. A comparison of bits 3, 0, and 0 produces the value m1 or 0.
Description
The BOOL function performs a Boolean operation on two bit-string arguments, x and y, and returns the result as a bit string with the length of the longer argument.
z should be a bit string 4 bits long. If not, it is converted to Bit (4).
If x and y are null strings, the result is a null string. If x is not the same length as y, the shorter string is extended on the right with zero bits until x and y are the same length. The bit values within z are m1, m2, m3, m4 from left-to-right, respectively.
The Ith bit value of the result is set to one of the values m1, m2, m3, m4 depending on the Ith bit value of x and y according to table below.
In other words, bit string z defines the result of some Boolean function. For instance, to define the function OR, the value of bit string z is given as '0111'b. To define the function AND, bit string z is '0001'b. The result is a bit string of the same length as x and y, obtained by applying the function rule described by z to each bit position of string x and string y.