Positron Compiler Documentation

Floating Point Exception Flags

Source: Positron8 Compiler User Manual, PDF page 32

The floating point exception flags are accessible from within the BASIC program via the system variable: _FP_FLAGS. This must be brought into the BASIC program for the code to recognise it:

Dim _FP_FLAGS as Byte System

The exceptions are:

_FP_FLAGS.1
                 ' Floating point overflow
_FP_FLAGS.2
                 ' Floating point underflow
_FP_FLAGS.3
                 ' Floating point divide by zero
_FP_FLAGS.5
                 ' Domain error exception

The exception bits can be aliased for more readability within the program:

Symbol FpOverflow
                      = _FP_FLAGS.1  ' Floating point overflow
Symbol FpUnderFlow  = _FP_FLAGS.2  ' Floating point underflow
Symbol FpDiv0
                      = _FP_FLAGS.3  ' Floating point divide by zero
Symbol FpDomainError  = _FP_FLAGS.5  ' Domain error exception

After an exception is detected and handled in the program, the exception bit should be cleared so that new exceptions can be detected, however, exceptions can be ignored because new operations are not affected by old exceptions.

More Accurate Display or Conversion of Floating Point values.

By default, the compiler uses a relatively small routine for converting floating point values to decimal, ready for Rsout, Print, HRsout etc. However, because of its size, it does not perform any rounding of the value first, and is only capable of converting relatively small values. i.e. approx 5 digits of accuracy. In order to produce a more accurate result, the compiler needs to use a larger routine. This is implemented by using a Declare: -

Declare Float_Display_Type = Fast or Standard

Using the Fast model for the above declare will trigger the compiler into using the more accurate floating point to ASCII decimal routine. Note that even though the routine is larger than the standard converter, it operates much faster.

The compiler defaults to Standard if the Declare is not issued in the BASIC program.

See also

Dim, Symbol, Aliases, Arrays, Constants.