GPC has three built-in floating point types to represent real numbers. Each of them is available under two names (for compatibility to other compilers and languages).
For most purposes, you will always use Real
which is the only
one of them that is part of Standard and Extended Pascal. If memory
constraints apply, you might want to choose ShortReal
for
larger arrays. On the other hand, if high precision is needed, you
can use LongReal
. When interfacing with libraries written in
other languages such as C, you will need the equivalents for their
real types.
Note that not all machines support longer floating point types, so
LongReal
is the same as Real
on these machines. Also,
some machines may support a longer type, but not do all arithmetic
operations (e.g. the Sin
function, Sin) in a precision
higher than that of Real
. If you need higher precision, you
can look at the GMP
unit (see GMP) which provides
rational and real numbers with arbitrary precision, but their usage
is different from normal real types.
The following real types are guaranteed to be compatible to the real types of GNU C. The sizes given, however, are not guaranteed. They are just typical values used on any IEEE compatible floating point hardware, but they may be different on some machines.
type name | alternative name | GNU C equivalent | size in bits (typically)
|
ShortReal | Single | float | 32
|
Real | Double | double | 64
|
LongReal | Extended | long double | 80
|