Sign in Join
Wiki copytemporary

false and true

The constants false and true are used to define the false and true conditions of a boolean variable. They are manifest constants that are defined as part of the standard data types the compiler initially knows about.

These constant values must be predefined by the compiler as there is no way to define them in terms of anything else. They are defined via compiler/psystem.pas as part of the system unit.

As of FPC 3.0.0 false and true are no longer reserved words. Thus the following program is valid, compiles and is “usable”:

pascal
program falseAndTrue(input, output, stderr);
    
    const
        true = 42;
    
    begin
        writeLn(true);                 // prints 42
        //writeLn(true and false);     // does not compile
        writeLn(system.true and false) // prints FALSE
    end.

Internal value

pascal
program falseDemo(input, output, stderr);
    
    uses
        typInfo;
    
    begin
        writeLn(false);                            // prints FALSE
        
        // enumerative actions ------------------------------------------
        writeLn(ord(false));                       // prints 0
        writeLn(succ(false));                      // prints TRUE
        // next two statements generate compile errors
            // "Error: range check error while evaluating constants (-1 must be between 0 and 1)"
        writeLn(pred(false));
            // " Error: range check error while evaluating constants (2 must be between 0 and 1)"                      
        writeLn(succ(succ(false)));                
        
        // data type ----------------------------------------------------
        writeLn(sizeOf(false));                    // prints 1
        writeLn(bitSizeOf(false));                 // prints 8
        writeLn(PTypeInfo(typeInfo(false))^.kind); // prints tkBool
        writeLn(PTypeInfo(typeInfo(false))^.name); // prints Boolean
    end.

When typecasting or interpreting any numeric value as a boolean value, it is important to know, that any non-zero value means true whilst only 0 (zero) is false.

Confer ISO 7185 § “Required simple-types”.

Two types of True

(according to developer PascalDragon) There are two types of True in Pascal:

VALUES SUMMARY

· | Boolean | Boolean8 | Boolean16 | Boolean32 | Boolean64 | ByteBool | WordBool | LongBool | QWordBool
false | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
true | 1 | 1 | 1 | 1 | 1 | 1..FF | 1..FFFF | 1..FFFFFFFF | 1..FFFFFFFFFFFFFFFF
undefined | 2..FF | 2..FF | 2..FFFF | 2..FFFFFFFF | 2..FFFFFFFFFFFFFFFF | | | |

See also


From the Free Pascal wiki, page "false and true", as the Internet Archive kept it on 2026-02-06, last changed on 2025-08-06. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 2, last changed by WikiArchive .

Edited on wiki.freepascal.org by 9 people, 2005–2023

From the official wiki's backup of 26 May 2024: who edited this page there, and when. Edits made there after that date were not recorded, and the earlier versions are not shown here; the main page says why.

WhenWhoWhat changed
Rfc1394
Swen (minor)
Swen (minor)
Djzepi
Jwdietrich
Swen (minor)
FPC userFix internal link (minor)
FPC userinternal link
Kai Burghardtreview; add some example code
Djzepi
Kai BurghardtKai Burghardt moved page False to false and true: merge: deduplicate page contents (minor)
Kai Burghardtadjust page content to talk about _both_ false _and_ true
Kai Burghardtgrammar (minor)
Kai Burghardtuse Template:Translate; add hint about typecasting
Kai Burghardtadd Category:Code, Category:Pascal, Category:Reserved words
BartTrue and False ar NOT reserved words in fpc.
Kai Burghardtpast tense statement concerning reserved words
TrevFixed template loop (minor)
TrevFixed syntax highlighting; deleted category included in page template (minor)
TrevCorrected the status of false and true as of FPC 3.0 (minor)
Kai Burghardtreplace legacy syntaxhighlight syntax; partially undo revision 133640 (re-introduce :Category: Code); add some external references (minor)
AlextppSee also
AlextppTwo types of True
AlextppTwo types of True
FPC userInternal value: update to current 3.2.2 compiler behavior

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.