PATCH: Visual C++ sin(), cos(), and tan() Incorrect w/ 287

Last reviewed: May 23, 1997
Article ID: Q126882
The information in this article applies to:
  • The C Run-time (CRT) included with: - Microsoft Visual C++ for Windows, versions 1.0, 1.5, 1.51, 1.52

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.

CAUSE

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.

RESOLUTION

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 (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

STATUS

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.

MORE INFORMATION

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.

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 );
   }

Results

The 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.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

 

	
	


Keywords : CRTIss kbfile kbhw kbprg kbbuglist kbfixlist
Version : 1.00 1.50 1.51 1.52
Platform : WINDOWS
Resolution Type : kbpatch


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: May 23, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.