Visual C++ sin(), cos(), and tan() Incorrect w/ 287 |
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 files are available for download from the Microsoft
Download Center:
Vc287p.exe
For additional information about how to download Microsoft Support
files, click the article number below
to view the article in the Microsoft Knowledge Base:
Q119591 How to Obtain Microsoft Support Files from Online ServicesMicrosoft used the most current virus detection software available on the date of posting to scan this file for viruses. Once posted, the file is housed on secure servers that prevent any unauthorized changes to the file.
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 kbprogramming kb16bitonly kbCRT kbVC
Issue type :
Technology : kbVCsearch kbAudDeveloper kbCRT
|
Last Reviewed: May 8, 2001 © 2001 Microsoft Corporation. All rights reserved. Terms of Use. |