Apple II User Manual

Page of 257
+------------------------------------------------------------------------
|  TOPIC -- Apple II -- WOZPAK Floating point routines description
+------------------------------------------------------------------------
Wozpak ][, November 1979, pages 109-115.
FLOATING POINT PACKAGE
The mantissa-exponent, or 'floating point' numerical representation is
widely used by computers to express values with a wide dynamic range.  With
floating point representation, the number 7.5 x 10^22 requires no more
memory to store than the number 75 does.  We have allowed for binary
floating point arithmetic on the APPLE ][ computer by providing a useful
subroutine package in ROM, which performs the common arithmetic functions.
Maximum precision is retained by these routines and overflow conditions
such as 'divide by zero' are trapped for the user.  The 4-byte floating
point number representation is compatible with future APPLE products such
as floating point BASIC.
A small amount of memory in Page Zero is dedicated to the floating point
workspace, including the two floating-point accumulators, FP1 and FP2.
After placing operands in these accumulators, the user calls subroutines in
the ROM which perform the desired arithmetic operations, leaving results in
FP1.  Should an overflow condition occur, a jump to location $3F5 is
executed, allowing a user routine to take appropriate action.
        FLOATING POINT REPRESENTATION
      _____    _____    _____    _____
     |     |  |     |  |     |  |     |
     |     |  | HI  |  |     |  | LOW |
     |_____|  |_____|  |_____|  |_____|
    Exponent       Signed Mantissa
1.  Mantissa
The floating point mantissa is stored in two's complement representation
with the sign at the most significant bit (MSB) position of the high-order
mantissa byte.  The mantissa provides 24 bits of precision, including sign,
and can represent 24-bit integers precisely.  Extending precision is simply
a matter of adding bytes at the low order end of the mantissa.
Except for magnitudes less than 2^-128 (which lose precision) mantissa are
normalized by the floating point routines to retain maximum precision.
That is, the numbers are adjusted so that the upper two high-order mantissa
bits are unequal.
      HIGH-ORDER MANTISSA BYTE
     01.XXXXXX  Positive mantissa.
     10.XXXXXX  Negative mantissa.
     00.XXXXXX  Unnormalized mantissa.
     11.XXXXXX  Exponent = -128.
2.  Exponent.