PRB: Long Doubles Are Not Supported when Using Alternate Math

ID Number: Q73851

6.00 6.00a 6.00ax | 6.00 6.00a

MS-DOS | OS/2

buglist6.00 buglist6.00a buglist6.00ax

Summary:

SYMPTOMS

In Microsoft C versions 6.0, 6.0a, and 6.0ax, using long doubles

programs that link with the alternate math libraries can cause

unexpected errors.

CAUSE

The long double data type is not supported in Microsoft C alternate

math libraries. This includes both the standard run-time libraries

(xLIBCAx.LIB) and the standalone DLL library (LLIBCDLL.LIB). The

reason for this is that long double support requires 80-bit (10

byte) reals. Alternate math uses 64-bit (8 byte) reals for

performance reasons.

STATUS

Microsoft has confirmed this to be a problem in C versions 6.0,

6.0a, and 6.0ax. We are researching this problem and will post new

information here as it becomes available.

More Information:

Section 4.2 of the "Microsoft C Advanced Programming Techniques"

manual states:

All of the Microsoft C run-time Libraries support type long

double. Each of the normal floating-point math functions has a

special version that supports type long double.

The standard coprocessor and emulator libraries use long doubles as

the default data type. To generate the fastest code possible, the

alternate math libraries only use doubles. While the alternate math

libraries do have special versions of the functions that should

support long doubles, these functions may cause errors or invalid

results when used. For example, when the sample program below is

compiled with /FPa, it generates the following error when run:

run-tine error R6002

- floating-point support not loaded

If the long double format specifier is removed from the printf(), you

would see that the result of the conversion from long double to int on

the line before is also incorrect.

For more information on long doubles or alternate math, see chapter 4

in "Microsoft C Advanced Programming Techniques."

Sample Code

-----------

/* Compile options needed: /FPa

*/

#include <stdio.h>

long double ld = 17.0;

void main (void)

{

int i;

i = (int)ld;

printf("Int i = %d\t and Long Double ld = %Lf", i, ld );

}

Additional reference words: R6001 R6003 6.00 6.00a 6.00ax