Floating-point literals can be assigned to
1program realDemo(input, output, stderr); 2 3var 4 r: real; 5 6begin 7 r := 0.; // r becomes zero 8 writeLn(r, ' ', r:8:4); 9 10 r := 1e2; // r becomes 1*(10^2) [a hundred] 11 writeLn(r, ' ', r:8:4); 12 13 r := r / r; // r becomes one 14 writeLn(r, ' ', r:8:4); 15end.
real, like all floating-point types, supports
/ division operator, while integer types support
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
realtype had a special internal format, under Free Pascal the
realtype simply maps to one of the other real types. It maps to the
doubletype on processors which support floating point operations, while it maps to the
singletype 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.
|simple data types|
|complex data types|