PATCH: Visual C++ sin(), cos(), and tan() Incorrect w/ 287Last reviewed: May 23, 1997Article ID: Q126882 |
The information in this article applies to:
SYMPTOMS Calls to the sin(), cos(), or tan() in a program built with the Visual C++ versions listed at the beginning of this article return incorrect results.
CAUSEThis is caused by a bug in the Visual C++ run-time (CRT) functions. The functions have a problem with 287 synchronization on 80286 systems with 80287 coprocessors. The timing problem does not affect programs running on an 80386 with an 80387 coprocessor, on an 80486, or on a Pentium processor.
RESOLUTIONYou can get a patch (VC287P.EXE) to fix a bug that occurs with the sin(), cos(), and tan() run-time functions. These functions return incorrect values when a program built with Visual C++ is run on a computer that has both an 80286 processor and an 80287 math coprocessor. The following file is available for download from the Microsoft Software Library:
~ Vc287p.exe (size: 19930 bytes)For more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q119591 TITLE : How to Obtain Microsoft Support Files from Online Services STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This problem was corrected in the patch announced in this article.
MORE INFORMATIONPlease note that this patch is a partially tested fix for this problem. No problems have been detected with it, however it has not gone through a full product test cycle. Microsoft makes no guarantees for its useability or functionality. See the LEGAL.TXT included with the patch for more details. The patch also contains a README.TXT with installation details and the information in this article.
Sample Code to Reproduce Problem
/* Compile options needed: None */ #include <math.h> #include <stdio.h> #include <stdlib.h> void main(void) { double x; x=1.0; printf( "cos(x) = %lf, sin(x) = %lf, tan(x) = %lf, x = %lf\n", cos(x), sin(x), tan(x), x ); } ResultsThe following correct output was produced on a 286/287 with NO87=1:
cos(x) = 0.540302, sin(x) = 0.841471, tan(x) = 1.557408, x = 1.000000The following incorrect output was produced on a 286/287 with NO87 not set:
cos(x) = 1.000000, sin(x) = 2.000000, tan(x) = 0.000000, x = 1.000000 |
Keywords : CRTIss kbfile kbhw kbprg kbbuglist kbfixlist
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |