home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / pent_bug.zip / pentium.cpp < prev   
C/C++ Source or Header  |  1994-11-19  |  904b  |  34 lines

  1. #include <iostream.h>
  2. #include <math.h>
  3. #include <iomanip.h>
  4.  
  5. void main() {
  6.     double x,y,z;
  7.     x = 4195835.0;
  8.     y = 3145727.0;
  9. /*
  10.   Divide x by y
  11.   The correct answer is 1.333 820 449 136 241. Bad Pentiums'll return
  12.   1.333 739 068 902 038. That's wrong.
  13. */
  14.    z = x - (x / y) * y ;
  15.  
  16.    if ( fabs(z) >= 1.e-1)  {
  17.          cout << " This CPU has the FDIV bug " << endl;
  18.       cout << " 4195835 / 3145727 should equal 1.333820449136241 " 
  19.            << endl <<  " while your CPU yields " ;
  20.       cout <<  "         " << setprecision(16)
  21.            << x/y << endl ;
  22.      }      
  23.    else
  24.          cout << "This CPU does not have the FDIV bug " << endl;
  25.  
  26. /*
  27.    Another example 
  28.    cout << (1.0/824633702449.0)*824633702449.0 << " should be 1" << endl ;
  29.    cout << 824633702449.0 - (1.0/824633702449.0)*824633702449.0*824633702449.0
  30.         << " should be 0" ;
  31. */
  32.        return;
  33. }
  34.