This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

Linux doubles precision bug?


Running the same code gives me different results on Linux 32 bit and 64
bit computers.  I'm not sure if it is a bug or not but other compilers
give the same results when run on 32 and 64-bit systems.
 
Let me know if you want me to submit a bug.
 
----------------------------------------------------------
#include <stdio.h>
int main()
{
  double x1, x2, x3, x;
 
  x1 = 43;
  x2 = (double) (4.0/60.0);
  x3 = (double) (16.0/3600.0);
 
  x = x1 + x2 + x3;
 
  printf("%25.20f = %25.20f, %25.20f, %25.20f\n",x, x1, x2, x3);
  return 0;
}
----------------------------------------------------------
 
Result for Linux 64-bit build using gcc version 4.1.1 20070105 (Red Hat
4.1.1-52)
Result for Solaris 32-bit build using CC: Sun C++ 5.8 2005/10/13
Result for Solaris 64-bit build using CC: Sun C++ 5.8 2005/10/13
  43.07111111111111512173 =   43.00000000000000000000,
0.06666666666666666574,    0.00444444444444444444

Result for Linux 32-bit build using gcc version 4.1.1 20070105 (Red Hat
4.1.1-52)
  43.07111111111110801630 =   43.00000000000000000000,
0.06666666666666666574,    0.00444444444444444444

----------------------------------------------------------
 
Thanks
Betty Evans


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