From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111c93,fd21959b44c0a9b0,start X-Google-Attributes: gid111c93,public X-Google-Thread: 10ba33,fd21959b44c0a9b0,start X-Google-Attributes: gid10ba33,public From: C R Johnson Subject: small doubles, g++, glibc, and linux/alpha problems Date: 1998/03/08 Message-ID: <3503303E.3E5B5838@ix.netcom.com>#1/1 X-Deja-AN: 332071628 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Organization: Netcom X-NETCOM-Date: Sun Mar 08 5:56:43 PM CST 1998 Mime-Version: 1.0 Newsgroups: gnu.g++.help,comp.os.linux.alpha g++ 2.7 and egcs 1.0.1 running on a linux-alpha-glibc system is not taking kindly to small double values - those funky near zero values that you know should be zero, but have stupid values like 2.38723e-314. The problem does not show itself on my linux-intel-glibc system. #include #include int main() { cerr << "hello" << endl; double u = 2.38723e-314; cerr << "u = " << u << " M_PI = " << M_PI << endl; cerr << "u * M_PI = " << u * M_PI << endl; return 0; } The results: on linux - alpha - glibc +++++++++++++++++++++++++++++++++++++ [cliff@van cliff]$ g++ hello.c++ -g -o hello <-- using gcc 2.7.1 [cliff@van cliff]$ ./hello hello u = Floating point exception (core dumped) [cliff@van cliff]$ eg++ hello.c++ -g -o hello <-- using egcs 1.0.1 [cliff@van cliff]$ ./hello hello u = 2.38723e-314 M_PI = 3.14159 u * M_PI = Floating point exception (core dumped) slightly different results, but both hosed. on linux - intel - glibc +++++++++++++++++++++++++ [cliff@brother_brent cliff]$ eg++ hello.c++ -g -o hello [cliff@brother_brent cliff]$ hello hello u = 2.38723e-314 M_PI = 3.14159 u * M_PI = 7.4997e-314 No problem ( with either compiler ) . Can anybody explain this? Is it a known problem? Can it be fixed. Must I resort to float's? Thanks for any help. cliff