This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: Differences (performance/precision) between 32/64-bit exp
- From: "Ángel González" <keisial at gmail dot com>
- To: Dennis Wassel <dwassel at math dot uni-bremen dot de>
- Cc: libc-help at sourceware dot org
- Date: Thu, 14 Apr 2011 00:56:43 +0200
- Subject: Re: Differences (performance/precision) between 32/64-bit exp
- References: <4DA31F1F.0@math.uni-bremen.de>
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