Delphi Language Guide Delphi for Microsoft Win32 Delphi for the Microsoft. Net framework


Boolean ByteBool, WordBool, LongBool



Yüklə 0,84 Mb.
Pdf görüntüsü
səhifə77/294
tarix02.01.2022
ölçüsü0,84 Mb.
#41395
1   ...   73   74   75   76   77   78   79   80   ...   294
DelphiLanguageGuide

Boolean
ByteBool, WordBool, LongBool
False < True
False <> True
Ord(False) = 0
Ord(False) = 0
Ord(True) = 1
Ord(True) <> 0
Succ(False) = True Succ(False) = True
Pred(True) = False Pred(False) = True
A value of type ByteBool, LongBool, or WordBool is considered True when its ordinality is nonzero. If such a value
appears in a context where a Boolean is expected, the compiler automatically converts any value of nonzero
ordinality to True.
64


The previous remarks refer to the ordinality of Boolean values, not to the values themselves. In Delphi, Boolean
expressions cannot be equated with integers or reals. Hence, if X is an integer variable, the statement
if X then ...;
generates a compilation error. Casting the variable to a Boolean type is unreliable, but each of the following
alternatives will work.
if X <> 0 then ...; { use longer expression that returns Boolean value }
          
var OK: Boolean;
 ...
if X <> 0 then OK := True;
if OK then ...;

Yüklə 0,84 Mb.

Dostları ilə paylaş:
1   ...   73   74   75   76   77   78   79   80   ...   294




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin