E

Errors in Floating-Point Numbers and Operations

On a 352 CPU, overflow occurs when a number greater than 3.402823E+38 or less than

-3.402823E+38 is generated by a REAL function. On all other 90-30 models that support floating point operations, the range is greater than 216 or less than –216.When your number exceeds the range, the ok output of the function is set OFF; and the result is set to positive infinity (for a number greater than 3.402823E+38 on a 352 CPU or 216 on all other models) or negative infinity (for a number less than –3.402823E+38 or –216on all other models). You can determine where this occurs by testing the sense of the ok output.

POS_INF

=

7F800000h

IEEE positive infinity representation in hex.

NEG_INF

=

FF800000h

IEEE negative infinity representation in hex.

Note

If you are using software floating point (all models capable of floating point operations except the 352 CPU), numbers are rounded to zero (0) at

±1.175494E–38.

If the infinities produced by overflow are used as operands to other REAL functions, they may cause an undefined result. This undefined result is referred to as an NaN (Not a Number). For example, the result of adding positive infinity to negative infinity is undefined. When the ADD_REAL function is invoked with positive infinity and negative infinity as its operands, it produces an NaN for its result.

On a 352 CPU, each REAL function capable of producing an NaN produces a specialized NaN which identifies the function:

NaN_ADD.

= 7F81FFFFh

– Real addition error value in hex.

NaN_SUB

= 7F81FFFFh

– Real subtraction error value in hex.

NaN_MUL

= 7F82FFFFh

– Real multiplication error value in hex.

NaN_DIV

= 7F83FFFFh

– Real division error value in hex.

NaN_SQRT

= 7F84FFFFh

– Real square root error value in hex.

NaN_LOG

= 7F85FFFFh

– Real logarithm error value in hex.

NaN_POW0

= 7F86FFFFh

– Real exponent error value in hex.

NaN_SIN

= 7F87FFFFh

– Real sine error value in hex.

NaN_COS

= 7F88FFFFh

– Real cosine error value in hex.

NaN_TAN

= 7F89FFFFh

– Real tangent error value in hex.

NaN_ASIN

= 7F8AFFFFh

– Real inverse sine error value in hex.

NaN_ACOS

= 7F8BFFFFh

– Real inverse cosine error value in hex.

NaN_BCD

= 7F8CFFFFh

BCD-4 to real error.

REAL_INDEF

= FFC00000h

– Real indefinite, divide 0 by 0 error.

All other CPUs that support floating point operations produce one (1) Nan output: FFFF FFFF.

When an NaN result is fed into another function, it passes through to the result. For example, if an NaN_ADD is the first operand to the SUB_REAL function, the result of the SUB_REAL is NaN_ADD. If both operands to a function are NaNs, the first operand will pass through. Because

E-6

Series 90-30/20/Micro Programmable Controllers Reference Manual–September 1998

GFK-0467K

Page 301
Image 301
GE 90-30/20/Micro manual Errors in Floating-Point Numbers and Operations, Posinf, Neginf, Realindef