This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Differences (performance/precision) between 32/64-bit exp


Dennis Wassel wrote:
> Steps to reproduce:
> Compile and run this program as 32 and 64 bit binary.
>
> -------- >8 ---------------- >8 ---------------- >8 --------
> #include <stdlib.h>
> #include <stdio.h>
> #include <math.h>
>
> void work (double x) {
>   printf("x = %25.16e, exp(x) = %25.16e\n", x, exp(x));
> }
>
> int main (void) {
>   double eps = pow (2, - 53);
>   work(eps);
>   return EXIT_SUCCESS;
> }
> -------- 8< ---------------- 8< ---------------- 8< --------
>
> Output differs like this:
>
> $ diff -Bupw 32.log 64.log
> --- 32.log	2011-04-11 16:57:32.905706289 +0200
> +++ 64.log	2011-04-11 16:57:33.275706197 +0200
> @@ -1 +1 @@
> -x =    1.1102230246251565e-16, exp(x) =    1.0000000000000000e+00
> +x =    1.1102230246251565e-16, exp(x) =    1.0000000000000002e+00
>
I also get the 1.0000000000000002e+00 output when compiling as 32 bits
if using -O3 or
-O2  -finline-functions (in such case, the exp function is not even
called, it's resolved in compile time to the longs <1, 1072693248> and
<620756992>).

gcc 4.5.2




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]