Sun WorkShop Compiler C 5.0 User's Guide

Arithmetic Operations on Exceptional Values

This section describes the results derived from applying the basic arithmetic operations to combinations of exceptional and ordinary floating-point values. The information that follows assumes that no traps or any other exception actions are taken.

The following tables explain the abbreviations:

Table A-16 Abbreviation Usage

Abbreviation 

Meaning 

Num 

Subnormal or normal number  

Inf 

Infinity (positive or negative) 

NaN 

Not a number  

Uno 

Unordered 

The tables that follow describe the types of values that result from arithmetic operations performed with combinations of different types of operands.

Table A-17 Addition and Subtraction Results
 

 Right Operand  

Left Operand  

 0 

Num 

Inf 

NaN  

 0 

Num 

Inf 

NaN  

Num 

 Num 

See Note 

Inf 

NaN  

Inf 

 Inf 

Inf 

See Note 

NaN  

NaN 

 NaN 

NaN 

NaN 

NaN  


Note -

Num + Num could be Inf, rather than Num, when the result is too large (overflow). Inf + Inf = NaN when the infinities are of opposite sign.


Table A-18 Multiplication Results

 

 Right Operand  

Left Operand 

 0 

Num 

Inf 

NaN  

 0 

NaN 

NaN  

Num 

 0 

Num 

Inf 

NaN  

Inf 

 NaN 

Inf 

Inf 

NaN  

NaN 

 NaN 

NaN 

NaN 

NaN  

Table A-19 Division Results

 

 Right Operand  

Left Operand  

 0 

Num 

Inf 

NaN  

 NaN 

NaN  

Num 

 Inf 

Num 

NaN  

Inf 

 Inf 

Inf 

NaN 

NaN  

NaN 

 NaN 

NaN 

NaN 

NaN  

Table A-20 Comparison Results

 

 Right Operand  

Left Operand 

 0 

+Num 

+Inf 

NaN  

 = 

Uno  

+Num 

 > 

The result of the comparison 

Uno  

+Inf 

 > 

Uno  

NaN 

 Uno 

Uno 

Uno 

Uno  


Note -

NaN compared with NaN is unordered, and results in inequality. +0 compares equal to -0.