BUG: Format Specifications Give Incorrect OutputLast reviewed: August 7, 1997Article ID: Q145821 |
4.00 | 4.00 | 4.00WINDOWS NT | WINDOWS | MACINTOSH kbprg kbbuglist The information in this article applies to:
- Microsoft Visual C++, Macintosh Cross-Development, version 4.00 on the following platform: 68k Macintosh
SYMPTOMSWhen you use the C run-time functions such as sprintf when building a 68K Macintosh target, the format specification for long double (%ld, %le, %lg) yields incorrect output. This is not a problem with a Power Macintosh target.
RESOLUTIONUse other format specifications. Internally, do your calculations using long doubles. However, when it comes time to output final results, convert the result to a double, and use the corresponding format specification.
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATION
Code to Reproduce Problem
/* Compile options needed: default */ char buf[1000];long double ldReturn = 7.9718893639526417; sprintf(buf,"ldReturn(%%ld)=%ld\n", ldReturn);
/* Instead, do the following */ char buf[1000];long double ldReturn = 7.9718893639526417; sprintf(buf,"ldReturn(%%d)=%ld\n", (double)ldReturn);
|
Additional reference words: 4.00 Windows 95 Windows NT
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |