[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

General Programming Concepts: Writing and Debugging Programs

128-Bit Long Double Floating-Point Data Type

The AIX operating system supports a 128-bit long double data type that provides greater precision than the default 64-bit long double data type. The 128-bit data type can handle up to 31 significant digits (compared to 17 handled by the 64-bit long double). However, while this data type can store numbers with more precision than the 64-bit data type, it does not store numbers of greater magnitude.

The following special issues apply to the use of the 128-bit long double data type:

Compiling Programs that Use the 128-bit Long Double Data Type

To compile C programs that use the 128-bit long double data type, use the xlc128 command. This command is an alias to the xlc command with support for the 128-bit data type. The xlc command supports only the 64-bit long double data type.

The standard C library, libc.a provides replacements for libc.a routines which are implicitly sensitive to the size of long double. Link with the libc.a library when compiling applications that use the 64-bit long double data type. Link applications that use 128-bit long double values with both the libc128.a and libc.a libraries. When linking, be sure to specify the libc128.a library before the libc.a library in the library search order.

Compliance with IEEE 754 Standard

The 64-bit implementation of the long double data type is fully compliant with the IEEE 754 standard, but the 128-bit implementation is not. Use the 64-bit implementation in applications that must conform to the IEEE 754 standard.

The 128-bit implementation differs from the IEEE standard for long double in the following ways:

Implementing the 128-Bit Long Double Format

A 128-bit long double number consists of an ordered pair of 64-bit double-precision numbers. The first member of the ordered pair contains the high-order part of the number, and the second member contains the low-order part. The value of the long double quantity is the sum of the two 64-bit numbers.

Each of the two 64-bit numbers is itself a double-precision floating-point number with a sign, exponent, and significand. Typically the low-order member has a magnitude that is less than 0.5 units in the last place of the high part, so the values of the two 64-bit numbers do not overlap and the entire significand of the low-order number adds precision beyond the high-order number.

This representation results in several issues that must be considered in the use of these numbers:

Values of Numeric Macros

Because of the storage method for the long double data type, more than one number can satisfy certain values that are available as macros.The representation of 128-bit long double numbers means that the following macros required by standard C in the values.h file do not have clear meaning:

Number of Bits in the Mantissa

The number of bits in the significand is not fixed, but for a correctly formatted number (except in the denormal range) the minimum number available is 106. Therefore, the value of the LDBL_MANT_DIG macro is 106.


The ANSI C standard defines the value of epsilon as the difference between 1.0 and the least representable value greater than 1.0, that is, b**(1-p), where b is the radix (2) and p is the number of base b digits in the number. This definition requires that the number of base b digits is fixed, which is not true for 128-bit long double numbers.

The smallest representable value greater than 1.0 is this number:

0x3FF0000000000000, 0x0000000000000001

The difference between this value and 1.0 is this number:

0x0000000000000001, 0x0000000000000000

Because 128-bit numbers usually provide at least 106 bits of precision, an appropriate minimum value for p is 106. Thus, b**(1-p) and 2**(-105) yield this value:

0x3960000000000000, 0x0000000000000000

Both values satisfy the definition of epsilon according to standard C. The long double subroutines use the second value because it better characterizes the accuracy provided by the 128-bit implementation.

Maximum Long Double Value

The value of the LDBL_MAX macro is the largest 128-bit long double number that can be multiplied by 1.0 and yield the original number. This value is also the largest finite value that can be generated by primitive operations, such as multiplication and division:


Related Information

The cc command.

List of 128-Bit Long Double Numerical Manipulation Subroutines.

[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]