From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 24702 invoked from network); 30 Nov 1998 09:56:16 -0000 Received: from mail.redhat.com (199.183.24.239) by lists.redhat.com with SMTP; 30 Nov 1998 09:56:16 -0000 Received: from beach.frankfurt.netsurf.de (root@beach.frankfurt.netsurf.de [194.64.181.2]) by mail.redhat.com (8.8.7/8.8.7) with ESMTP id EAA24189 for ; Mon, 30 Nov 1998 04:54:14 -0500 Received: from Othello (deck-124.frankfurt.netsurf.de [194.64.181.156]) by beach.frankfurt.netsurf.de (8.8.5/8.8.5) with SMTP id KAA04269; Mon, 30 Nov 1998 10:54:12 +0100 (MET) Sender: fabwes@beach.frankfurt.netsurf.de Message-ID: <36626B12.3809D30E@frankfurt.netsurf.de> Date: Mon, 30 Nov 1998 10:53:23 +0100 From: Joachim Wesner X-Mailer: Mozilla 3.04Gold (X11; I; Linux 2.0.33 i586) MIME-Version: 1.0 To: axp-list@redhat.com Subject: Re: Floating point problems References: <199811300816.IAA24959@ppp393.ts.rz.tu-bs.de> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit y0000218@rzsrv2.rz.tu-bs.de wrote: > > Heinz Ulrich Stille 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