Handling differences in IEEE and hexadecimal data

To avoid most problems with the different representation between IEEE and hexadecimal floating-point data, use the FLOAT(BE) compiler option.

About this task

COBOL for Linux® on x86 represents floating-point data using the IEEE format. Enterprise COBOL for z/OS® uses the IBM Z® hexadecimal format. The following table summarizes the differences between normalized floating-point IEEE and normalized hexadecimal for USAGE COMP-1 data and USAGE COMP-2 data.

Table 1. IEEE contrasted with hexadecimal
Specification IEEE for COMP-1 data Hexadecimal for COMP-1 data IEEE for COMP-2 data Hexadecimal for COMP-2 data
Range 1.17E-38* to 3.37E+38* 5.4E-79* to 7.2E+75* 2.23E-308* to 1.67E+308* 5.4E-79* to 7.2E+75*
Exponent representation 8 bits 7 bits 11 bits 7 bits
Mantissa representation 23 bits 24 bits 53 bits 56 bits
Digits of accuracy 6 digits 6 digits 15 digits 16 digits
* Indicates that the value can be positive or negative.

For most programs, these differences should create no problems. However, use caution when porting if your program depends on hexadecimal representation of data.

Performance consideration: In general, IBM Z floating-point representation makes a program run more slowly because the software must simulate the semantics of IBM Z hardware instructions. This is a consideration especially if the FLOAT(BE) compiler option is in effect and a program has a large number of floating-point calculations.

Examples: numeric data and internal representation

Related references  
FLOAT