Sign in Join
Wiki copytemporary

false and true: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-The [[Constant|constants]] `false` and `true` are used to define the false and true conditions of a [[Boolean|boolean]] [[Variable|variable]]. They are [[Manifest constant|manifest constants]] that are defined as part of the [[Standard type|standard data types]] the [[Compiler|compiler]] initially knows about.
2-
3-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`](https://svn.freepascal.org/cgi-bin/viewvc.cgi/tags/release_3_2_0/compiler/psystem.pas?view=markup#l114) as part of the [[System unit|system unit]].
1+The [[Constant|constants]] `false` and `true` are used to define the false and true conditions of a [[Boolean|`boolean`]] [[Variable|variable]]. They are [[Manifest constant|manifest constants]] that are defined as part of the [[Standard type|standard data types]] the [[Compiler|compiler]] initially knows about.
42
5-As of [[FPC]] 3.0.0 `false` and `true` are **no longer** [[Reserved words|reserved words]]. Thus the following program is valid, compiles and is “usable”:
3+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`](<https://svn.freepascal.org/cgi-bin/viewvc.cgi/tags/release_3_2_0/compiler/psystem.pas?view=markup#l114>) as part of the [[System unit|system unit]].
64
7-``` pascal
5+As of [[FPC]] 3.0.0 `false` and `true` are **no longer** [[Reserved words|reserved words]]. Thus the following program is valid, compiles and is “usable”:
6+```
87program falseAndTrue(input, output, stderr);
9-
10-const
11- true = 42;
12-
13-begin
14- writeLn(true); // prints 42
15- //writeLn(true and false); // does not compile
16- writeLn(system.true and false) // prints FALSE
17-end.
8+
9+ const
10+ true = 42;
11+
12+ begin
13+ writeLn(true); // prints 42
14+ //writeLn(true and false); // does not compile
15+ writeLn(system.true and false) // prints FALSE
16+ end.
1817```
1918
2019## Internal value
21-
22-``` pascal
20+```
2321program falseDemo(input, output, stderr);
24-
25-uses
26- typInfo;
27-
28-begin
29- writeLn(false); // prints FALSE
3022
31- // enumerative actions ------------------------------------------
32- writeLn(ord(false)); // prints 0
33- writeLn(succ(false)); // prints TRUE
34- // next two statements generate compile errors
35- // "Error: range check error while evaluating constants (-1 must be between 0 and 1)"
36- writeLn(pred(false));
37- // " Error: range check error while evaluating constants (2 must be between 0 and 1)"
38- writeLn(succ(succ(false)));
23+ uses
24+ typInfo;
3925
40- // data type ----------------------------------------------------
41- writeLn(sizeOf(false)); // prints 1
42- writeLn(bitSizeOf(false)); // prints 8
43- writeLn(PTypeInfo(typeInfo(false))^.kind); // prints tkBool
44- writeLn(PTypeInfo(typeInfo(false))^.name); // prints Boolean
45-end.
26+ begin
27+ writeLn(false); // prints FALSE
28+
29+ // enumerative actions ------------------------------------------
30+ writeLn(ord(false)); // prints 0
31+ writeLn(succ(false)); // prints TRUE
32+ // next two statements generate compile errors
33+ // "Error: range check error while evaluating constants (-1 must be between 0 and 1)"
34+ writeLn(pred(false));
35+ // " Error: range check error while evaluating constants (2 must be between 0 and 1)"
36+ writeLn(succ(succ(false)));
37+
38+ // data type ----------------------------------------------------
39+ writeLn(sizeOf(false)); // prints 1
40+ writeLn(bitSizeOf(false)); // prints 8
41+ writeLn(PTypeInfo(typeInfo(false))^.kind); // prints tkBool
42+ writeLn(PTypeInfo(typeInfo(false))^.name); // prints Boolean
43+ end.
4644```
4745
48-When [[Typecast|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`.
46+When [[Typecast|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`.
4947
50-Confer [ISO 7185 § “Required simple-types”](http://pascal-central.com/iso7185.html#6.4.2.2%20Required%20simple-types).
48+Confer [ISO 7185 § “Required simple-types”](<http://pascal-central.com/iso7185.html#6.4.2.2%20Required%20simple-types>).
5149
5250## Two types of True
5351
54-(according to developer PascalDragon) There are two types of True in Pascal:
52+(according to developer PascalDragon) There are two types of True in Pascal:
5553
56-- the True for **Boolean**, **Boolean8**, **Boolean16**, **Boolean32** and **Boolean64** has the value 1, anything else (except 0 for False) is undefined.
57-- for **ByteBool**, **WordBool**, **LongBool** (the type for the Windows API's **BOOL**) and **QWordBool** any value that is not 0 is True, but if you assign True to such a type it will have the value "not 0" in the appropriate bit width.
54+ * the True for **Boolean** , **Boolean8** , **Boolean16** , **Boolean32** and **Boolean64** has the value 1, anything else (except 0 for False) is undefined.
55+ * for **ByteBool** , **WordBool** , **LongBool** (the type for the Windows API's **BOOL**) and **QWordBool** any value that is not 0 is True, but if you assign True to such a type it will have the value "not 0" in the appropriate bit width.
5856
57+**VALUES SUMMARY**
58+---
59+**·** | **Boolean** | **Boolean8** | **Boolean16** | **Boolean32** | **Boolean64** | **ByteBool** | **WordBool** | **LongBool** | **QWordBool**
60+false | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
61+true | 1 | 1 | 1 | 1 | 1 | 1..FF | 1..FFFF | 1..FFFFFFFF | 1..FFFFFFFFFFFFFFFF
62+undefined | 2..FF | 2..FF | 2..FFFF | 2..FFFFFFFF | 2..FFFFFFFFFFFFFFFF | | | |
63+
5964## See also
6065
61-- [[Boolean]]
66+ * [[Boolean]]
6267
6368---
64-*From the Free Pascal wiki, page "false and true", as it stood on 2023-10-18 after a change by FPC user, out of the wiki's dump of 2024-05-26. 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](/wiki-contact).*
65-Category: Code
69+*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](/wiki-contact).*

Back to history