From Free Pascal wiki
Revision as of 16:36, 6 March 2022 by Alextp (talk | contribs) (→‎alternatives: del dead svn link)
Jump to navigationJump to search

Deutsch (de) English (en) français (fr) русский (ru)

real is a standard type of the Pascal programming language.


Floating-point literals can be assigned to real variables.

 1program realDemo(input, output, stderr);
 4	r: real;
 7	r := 0.; // r becomes zero
 8	writeLn(r, ' ', r:8:4);
10	r := 1e2; // r becomes 1*(10^2) [a hundred]
11	writeLn(r, ' ', r:8:4);
13	r := r / r; // r becomes one
14	writeLn(r, ' ', r:8:4);

real, like all floating-point types, supports / division operator, while integer types support div-operator.

internal representation

The internal representation of the type real (i.e. number of bytes and byte ordering) and the resulting range and precision are platform dependent.

Quote from the “FreePascal Programmer's Manual” (Chapter 8.2.5 Floating point types):

Contrary to Turbo Pascal, where the real type had a special internal format, under Free Pascal the real type simply maps to one of the other real types. It maps to the double type on processors which support floating point operations, while it maps to the single type on processors which do not support floating point operations in hardware.


Instead of specifying real in your code, write ValReal, a type alias defined by the System unit. It automatically maps to the largest available floating point type available: single, double or extended.

navigation bar: data types
simple data types

boolean byte cardinal char currency double dword extended int8 int16 int32 int64 integer longint real shortint single smallint pointer qword word

complex data types

array class object record set string shortstring