PATCH: Visual C++ sin(), cos(), and tan() Incorrect w/ 287ID: Q126882
|
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.
This 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.
You 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
For more information about downloading files from the Microsoft Software
Library, please see the following article in the Microsoft Knowledge Base:
Q119591 How to Obtain Microsoft Support Files from Online Services
Microsoft 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.
Please 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.
/* 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 );
}
cos(x) = 0.540302, sin(x) = 0.841471, tan(x) = 1.557408, x = 1.000000
The 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
Additional query words:
Keywords : kbfile kbhw kbprg kbCRT kbVC
Version : 1.00 1.50 1.51 1.52
Platform : WINDOWS
Issue type :
Last Reviewed: July 27, 1999