178 AND AND can be used either as a logical operator or as a ‘bit by bit’, or ‘Boolean’ operator. Purpose As a logical operator AND is used to ensure that two conditions are met before something is done. For example IF X=9 AND Y=0 THEN PRINT "HELLO" Logical AND is most often used as part of an IF...AND...THEN... construction. Boolean AND compares the first bit of one number with the first bit of another number. If both bits are set to a one (rather than a zero) then the first bit in the answer is also set to a one. This process is then repeated for the second bit in each of the two numbers being compared and so on for all 32 bits in the numbers.
For example the result of 14 AND 7 is 6, since in binary 14 is 0000 0000 0000 0000 0000 0000 0000 1110 7 is 0000 0000 0000 0000 0000 0000 0000 0111 6 is 0000 0000 0000 0000 0000 0000 0000 0110 Examples 300 IF length>9 AND wt>9 THEN PRINT "YES" 100 IF X=2 AND cost>5 AND J=12 THEN PRINT "NO!!" The above example will only print NO!! if all three conditions are met. Description The operation of Boolean AND between two items. Note that the logical and Boolean operations are in fact equivalent.
This follows since the value of TRUE is -1 which is represented on this machine by the binary number 1111 1111 1111 1111 1111 1111 1111 1111 Similarly the binary value of FALSE is 0000 0000 0000 0000 0000 0000 0000 0000 Thus PRINT 6=6 would print -1 since 6=6 is TRUE .