MA01CD

Safely computing the sign of a sum of two real numbers represented using integer powers of a base

[Specification] [Arguments] [Method] [References] [Comments] [Example]

Purpose

  To compute, without over- or underflow, the sign of the sum of two
  real numbers represented using integer powers of a base (usually,
  the machine base). Any base can be used, but it should the same
  for both numbers. The result is an integer with value 1, 0, or -1,
  depending on the sum being found as positive, zero, or negative,
  respectively.

Specification
      INTEGER FUNCTION MA01CD( A, IA, B, IB )
C     .. Scalar Arguments ..
      INTEGER           IA, IB
      DOUBLE PRECISION  A, B

Function Value
  MA01CD  INTEGER
          The sign of the sum of the two numbers, which is usually
          either 1, or -1. If both numbers are 0, or if they have
          the same exponent and their sum is 0, the returned value
          is 0.

Arguments

Input/Output Parameters

  A       (input)  DOUBLE PRECISION
          The first real scalar.

  IA      (input)  INTEGER
          Exponent of the base for the first real scalar. The scalar
          is represented as A * BASE**(IA).

  B       (input)  DOUBLE PRECISION
          The first real scalar.

  IB      (input)  INTEGER
          Exponent of the base for the first real scalar. The scalar
          is represented as B * BASE**(IB).

Further Comments
  None
Example

Program Text

  None
Program Data
  None
Program Results
  None

Return to Supporting Routines index