Difference between revisions of "false and true"

From Lazarus wiki
Jump to navigationJump to search
(adjust page content to talk about _both_ false _and_ true)
m (grammar)
Line 4: Line 4:
 
They are [[Manifest constant|manifest constants]] that are defined as part of the [[Standard type|standard data types]] the [[Compiler|compiler]] initially knows about.
 
They are [[Manifest constant|manifest constants]] that are defined as part of the [[Standard type|standard data types]] the [[Compiler|compiler]] initially knows about.
  
This constant values must be predefined by the compiler as there is no way to define them in terms of anything else.
+
These constant values must be predefined by the compiler as there is no way to define them in terms of anything else.
  
 
<syntaxhighlight lang="pascal">
 
<syntaxhighlight lang="pascal">

Revision as of 11:43, 4 May 2018

English (en)

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.

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 out-of-range compile-time warnings
	writeLn(pred(false));                      // prints TRUE
	writeLn(succ(succ(false)));                // prints TRUE
	
	// 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.