and
The And keyword is used in two different ways:
1. To perform a logical or boolean 'and' of two logical values. If both are true, then the result is true, otherwise, the result is false.
2. To perform a mathematical 'and' of two integers. The result is a bitwise 'and' of the two numbers. For example:
10110001 And 01100110 = 00100000
Example
Download This Source for Free Pascal
Uses
Sysutils; // for IntToHex function
var
num1, num2, num3 : Integer;
letter : Char;
begin
num1 := $25; // Binary value : 0010 0101
num2 := $32; // Binary value : 0011 0010
// And'ed value : 0010 0000 = $20 = 32 dec
letter := 'G';
// And used to return a Boolean value
if (num1 > 0) And (letter = 'G')
then Writeln('Both values are true')
else Writeln('None or only one true value');
// And used to perform a mathematical AND operation
num3 := num1 And num2;
Writeln('$25 And $32 = $',IntToHex(num3,2));
end.
Output
Both values are true
$25 And $32 = $20
See Also
Not,
Or,
Xor.