The following short program compares the value of pow(x, 0.5) to that 
returned by sqrt(x) for a range of values of x, and prints out any first 
case where the two do not agree. With the mingw family of compilers I had 
expected the Microsoft C library to be in use.

What I appear to see is
    linux (ubuntu 11.04 64-bit tested)   no output
    Mac   (snow leopard)                 no output
    gcc   (cygwin)                       no output
    gcc-3 -mno-cygwin         )
    i686-w64-mingw32-gcc      ) all different from each other
    x86_64-w64-mingw32-gcc    ) but all find discrepancies.

It is a totally fair cop if the Microsoft C library gives different 
results in the last bit for floating point elementary functions to gnu 
libraries, but is there an obvious reason why the three mingw varients
all give different answers. This showed up in regression testing something 
much larger across platforms.

          Arthur

====================
#include <stdio.h>
#include <math.h>

int main(int argc, char *argv[])
{
     double a, b, c;
     int i;
     for (i=0, a=1.0; i<10000000; i++)
     {   a *= 1.00000001;
         b = sqrt(a); c = pow(a, 0.5);
         if (b == c) continue;
         printf("%.17g %.17g %.17g\n", a, b, c);
         return 0;
     }
     return 0;
}
====================

acn1@panamint temp
$ gcc expt.c -o expt
acn1@panamint temp
$ ./expt
acn1@panamint temp
$ gcc-3 -mno-cygwin expt.c -o expt
acn1@panamint temp
$ ./expt
1.0241210164238141 1.011988644414459 1.0119886444144588
acn1@panamint temp
$ i686-w64-mingw32-gcc expt.c -o expt
acn1@panamint temp
$ ./expt
1.0004603659307831 1.000230156479389 1.0002301564793892
acn1@panamint temp
$ x86_64-w64-mingw32-gcc expt.c -o expt
acn1@panamint temp
$ ./expt
1.0000179101601867 1.0000089550399969 1.0000089550399971
acn1@panamint temp
==============================================================


------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to