Usenet comp.os.linux.alpha (1997-2013)
 help / color / mirror / Atom feed
From: "H.W. Stockman" <hwstock@swcp.com>
To: C R Johnson <iamcliff@ix.netcom.com>
Subject: Re: small doubles, g++, glibc, and linux/alpha problems
Date: 1998/03/08	[thread overview]
Message-ID: <35033E60.29BB@swcp.com> (raw)
In-Reply-To: 3503303E.3E5B5838@ix.netcom.com


C R Johnson wrote:
> 
> 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 <iostream.h>
> #include <cmath>
> 
> 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?

On an x86, 2.38723e-314 is a valid representation as a denormal,
and can be loaded onto the processor as such.  The alpha
does not handle denormals in the processor, and generates
an exception when they are encountered.  You can't represent
2.38723e-314 as a normal IEEE double precision number.



  reply	other threads:[~1998-03-08  5:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-03-08  5:00 small doubles, g++, glibc, and linux/alpha problems C R Johnson
1998-03-08  5:00 ` H.W. Stockman [this message]
1998-03-09  5:00 ` Michal Jaegermann
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox