The data types


Integer types

FPK-Pascal supports some predefined integer data types:

type
   byte = 0..255;
   shortint = -128..127;
   word = 0..65535;  
   integer = -32768..32767;
   longint = -2147483648..2147483647;

If a source is compiled with -Cr or the compiler switch {$R+} is set, the range of variables of this these types is checked if the variable is stored. In the case of a range check error a run time error is generated.

You can also define your one types with your ranges. FPK-Pascal uses then the bigger predefined type which matches, but does the range check with your ranges.

Example:

{$R+}
var
   w : word;
   myvar : 1..40000; { maps to word }

begin
   w:=35000; { Ok }
   w:=0; { Ok }
   w:=-1; { error }
   myvar:=35000; { Ok }
   myvar:=0; { error }
   myvar:=-1; { error }
end.

FPK-Pascal does all integer calculations with 32-bit signed e. g. all values are first converted to longint and then the calculation is done, so you should use longints as far as possible.

NOTE: The type cardinal is currently not supported.


Fix comma types

FPKPascal supports a 32 bit fix comma data type. This data type is useful if a the used computer hasn't a math coprocessor or a slow, like a 387, a 486 etc.

So, how does it work? Well there now is the 'fixed' type which acts the same way as the 'real' type. The type is compatible with the 'real' type, you can both assign a 'real' to a 'fixed' as a 'fixed' to a 'real'. If an expression contains both fixed and real types, the result type is a real.

Example:

var 
   a : fixed; 
   b : real;
begin 
   a:=2.0; {Assign 2.0 to a.} 
   b:=2.0; a:=b; {Convert b to fixed and assign it to a.} 
   writeln(a/b); {Convert a to real, make division and write.} 
   writeln(a/fixed(b)); {Convert b to fixed, make division and write.} 
end.

The parameter passing, function returning for the fixed data type works like for longinters. The size of a fixed is 4 bytes. The point is between then the lower and the higher word.

NOTE: There are no special sin, cos etc. routines for fixed data types, so the routines for reals are used.

Thanks to Daniel Mantione for this feature.


Floating point types

FPK-Pascal has several predefined floating point types: real, single, double and extended.

real is a 8 byte floating point type with 52 bit mantissa and 12 bit exponent.
All other types are mapped to this type.

The calculations are done with 80 bit because FPK-Pascal uses the math. coprocessor of the computer. If the coprocessor isn't available, you can install a coprocessor emulator.



klaempfl@haegar.cip.mw.tu-muenchen.de

Copyright (c) 1996,97 by Florian Klaempfl