Bool is of the longbool type.
Delphi defines four Boolean types: Boolean, bytebool, wordbool, and longbool. The following three Boolean types are introduced for compatibility with other languages. We recommend that you use the boolean type.
The memory usage of these four types of Boolean values is as follows:
Boolean 1 byte
Bytebool 1 byte
Wordbool 2 bytes (1 word)
Longbool 4 bytes (2 words)
For bytebool, wordbool, and longbool, the values of true constants are non-zero and false is zero. You can use the Ord function for verification;
For boolean type, the value of true constant is 1, and false is zero. In the context of the expected Boolean value, the compiler converts the non-zero values of bytebool, wordbool, and longbool to true.
However, in Delphi, Boolean expressions are incompatible with integer/real. The following table compares the similarities and differences between Boolean and bytebool/wordbool/longbool:
Boolean
False <true
Ord (false) = 0
Ord (true) = 1
Succ (false) = true
PRED (true) = false
Booltostr (true) =-1 // This function is abnormal.
Booltostr (false) = 0
ByteBool, WordBool, LongBool
False <> True
Ord (False) = 0
Ord (True) <> 0
Succ (False) = True
Pred (False) = True
BoolToStr is the most inexplicable function. It clearly states that the value of True is 1, but it tells us that True is-1. The original form of the function is:
Function BoolToStr (B: Boolean; UseBoolStrs: Boolean = False): string;
The following table lists the function conversion rules:
B UseBoolStrs Value of returned string
True False '-1'
True TrueBoolStrs array's first value (default, 'true ')
False '0'
False True FalseBoolStrs array's first value (default, 'false ')