LOGAND

Syntax

LOGAND integer1 integer2

Explanation

LOGAND outputs the bitwise logical AND of its two inputs. Each input is expressed internally as a sixteen digit binary number. A logical AND operation is performed on the pair of binary digits (bits) in each position, resulting in a sixteen bit integer.

The logical AND operation is defined on the binary digits 0 and 1 as follows:

LOGAND 0 0 = 0

LOGAND 1 0 = 0

LOGAND 0 1 = 0

LOGAND 1 1 = 1

See also LOGNOT, LOGOR, LOGXOR.

Examples

? LOGAND 2 1

Result: 0

?

2 in base 10 is 10 in base 2; 1 in base 10 is 01 in base 2. In the 1's place, LOGAND 0 1 = 0. In the 2's place, LOGAND 1 0 = 0. Thus, 00 base 2 is obtained. 00 base in 2 is 0 in base 10.

? LOGAND 2 3

Result: 2

?

2 in base 10 is 10 in base 2; 3 in base 10 is 11 in base 2. In the 1's place, LOGAND 0 1 = 0. In the 2's place, LOGAND 1 1 = 1. Thus, 10 base 2 is obtained. 10 in base 2 is 2 in base 10.