Boolean types


 Boolean types

There are four predefined boolean types: Boolean, WordBool, LongBool, and ByteBool.


   Boolean = (False, True);
   WordBool = (False, True);
   LongBool = (False, True);
   ByteBool = (False, True);


These types are the following sizes:

  - Boolean is Byte-sized (8 bits)
  - WordBool is Word-sized (16 bits)
  - LongBool is Longint-sized (32 bits)
  - ByteBool is Byte-sized (8 bits)

Because booleans are enumerated ordinal types, these relationships apply:

  False < True
  Ord(False) = 0
  Ord(True) = 1
  Succ(False) = True
  Pred(True) = False

Boolean is the preferred type and uses the least memory. ByteBool, WordBool, and LongBool exist primarily to provide compatibility with Windows .

In an expression, these relational operators produce results of type Boolean.

    =   <>   >   <   >=   <=   IN

For Windows compatibility, booleans can assume ordinal values other than 0 and 1.

A boolean expression is considered False when its ordinal value is 0, and True when its ordinal value is non-zero.

The not, and, or, and xor boolean operators work by testing for 0 (False) or

 non-zero (True), but always return a result with an ordinal value of 0 or 1.

Тэги: Boolean
| G+
Код для вставки: :: :: :: ::
Поделиться: // //