From: Joachim Wesner <joachim.wesner@frankfurt.netsurf.de>
To: axp-list@redhat.com
Subject: Re: Floating point problems
Date: Mon, 30 Nov 1998 10:53:23 +0100 [thread overview]
Message-ID: <36626B12.3809D30E@frankfurt.netsurf.de> (raw)
In-Reply-To: 199811300816.IAA24959@ppp393.ts.rz.tu-bs.de
y0000218@rzsrv2.rz.tu-bs.de wrote:
>
> Heinz Ulrich Stille <Heinz.Ulrich.Stille@mbi-os.de> wrote:
> : Hi!
>
> : What's wrong with the following program?
>
> : main() {
> : double x = 1.0;
> : x *= 1e-310;
> : }
>
> : This results in a floating point exception on my Ruffian (for values
> : somwhere between 1e-300 and 1e-325, independent of kernel and compiler),
> : but not on any intel. The assembler output seems to indicate that the
> : two values are just loaded into registers and multiplied.
> : What is going on?
>
> This looks _very_ familiar - I had the same problem, same range of numbers.
>
> It still reproducibly FP-exeptions on a RH 5.2 system here.
>
> I think its weird, and noone could plausibly tell me why yet.
>
> -mieee works, also fixing my code so it doesnt produce such
> small numbers did it.
>
> Could any guru tell me _why_ this code crashes?
>
> Just doing anything with a number around 1e-310 raises an FP exception,
> smaller _and_ larger numbers dont.
Numbers smaller around 1e-308 but larger 1e-324 are denormalized
numbers. Even smaller ones cannot be expressed in double precision and
will be replaced by zero already by the compiler in the constant used in
the above code.
Unfortunatelly, and this is one of the biggest flaws of the Alpha
architecture IMHO, the Alpha cannot handle denormalized numbers without
trapping and software support. I can't understand why DEC made that
choice, as it causes so many problems in much code. Clearly, FULL
denormalized handling maybe somewhat complicated, BUT a hardware option
that silently replaces/treats any denormal by/like zero would sure have
costed very few transistors and would have helped critical code alot, if
you really need the full precision, you could still activate the
trapping and use -mieee.
Joachim
next prev parent reply other threads:[~1998-11-30 9:56 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-11-30 8:16 Floating point problems y0000218
1998-11-30 9:08 ` Carles Perello
1998-11-30 9:53 ` Joachim Wesner [this message]
1998-11-30 14:22 ` Alvin Starr
1998-11-30 13:27 ` krebs
1998-11-30 17:06 ` Joachim Wesner
1998-12-03 0:48 ` Richard Henderson
1998-12-03 16:59 ` Greg Lindahl
1998-12-03 19:35 ` Joachim Wesner
1998-12-03 20:04 ` Richard Henderson
1998-12-03 20:16 ` Greg Lindahl
1998-12-03 23:44 ` Joachim Wesner
1998-12-01 8:42 ` Jochen Kuepper
-- strict thread matches above, loose matches on Subject: below --
1998-11-30 10:24 y0000218
1998-11-30 13:30 ` Alvin Starr
1998-12-03 0:48 ` Richard Henderson
1998-11-28 13:15 Heinz Ulrich Stille
1998-11-28 14:24 ` Johannes G.D. Hausmann
1998-11-28 13:58 ` Heinz Ulrich Stille
1998-11-28 14:48 ` Stefan Schroepfer
1998-11-28 14:57 ` Heinz Ulrich Stille
1998-11-29 13:15 ` Johannes G.D. Hausmann
1998-11-29 13:02 ` Heinz Ulrich Stille
1998-11-29 18:01 ` B. James Phillippe
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