FreePascal Information Logo Friend of FreePascal Compiler Title
Articles with Feedback, FPC News Library, PDF Collection, Mail Lists, Books, Newsgroups, IRC Open online discussion areas Research and Tutorials Tools, Compilers and Utilities Blurbs about us, advertising, etc.
Welcome to the FoFPC Pascal Language AND

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 Source IconDownload 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.
 Links and Products we find useful



ButtonGenerator.com
Valid XHTML 1.0 Transitional Internet Map
Programmer's Heaven
grat-i-fi-ca-tion - noun
the state of being gratified; great satisfaction.


"Friends of Free Pascal is, in my view, one of the best things to happen to FPC since the compiler first appeared"

Gary Funk
BoardWatch Magazine
Locations of visitors to this page world map hits counter
Copyright 2009 by 3F, LLC. All rights reserved. Worldwide.
Your request was processed by server #3 in 0.001566 secs.

sponsor
This sponsor helps us with our documentation