Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Jerry Feldman <gaf@ZK3.DEC.COM>
Subject: Re: Floating point exception
Date: Mon, 16 Dec 96 13:44:23 -0500	[thread overview]
Message-ID: <9612161844.AA11677@sauron.zk3.dec.com> (raw)
In-Reply-To: <199612152221.RAA06013@churchy.gnu.ai.mit.edu>

> >Anyone know why this program causes a floating point exception on the
> >Alpha?
> >
> >#include <float.h>
> >
> >int main()
> >{
> >	double a = 4.5;
> >
> >	if(a > DBL_MIN) {
> >		return 1;
> >	}
> >
> >	return 0;
> >}
> 
> My guess is that it's due to DBL_MIN being a denormal (aka subnormal?) and
> your system doesn't have the right software (library or OS??) installed to
> handle the hardware traps that happen when denormals are encountered.
> 
> Happens on my system too, but I have an ancient one.  New Craftworks CDs are
> sitting on a shelf awaiting a major overhaul of my Alpha and Intel -- I
> presume this will make this particular problem, among many others, go
> away.  ;-)
> 
> So, upgrading the Linux OS and libraries (libm.a and libc.a?) on your system
> might make this problem disappear after recompiling and relinking.
> 
>         tq vm, (burley)
I do not agree. DBL_MIN is defined as the minimum normalized number. 
The value should be:2.2250738585072014e-308.
The only library that comes into play here is libc, not libm. The numbers, 4.5 and DBL_MIN should be converted at compile time to the appropriate binary 
constants to be loaded. If the optimizer is smart enough, the code will just return 1, because it sees a as an effective constant. If not, it should generate assembly code similar to:
	        ldit    $f10, 4.5
		ldit    $f11, 2.2250738585072014e-308
		cmptlt  $f11, $f10, $f12
		fbeq    $f12, ret0
		ldil	$0, 1	# Return 1
		br	done
ret0:
		bis $31, $31, $0	# return 0
done:
		... unwind stack, restore any saved stuff
		ret

-- 
+--------------------------------------------------------------------+
Jerry Feldman            Digital Unix Development Environment
Digital Equipment Corp.  (work)gaf@zk3.dec.com (home)gaf@highway1.com
110 Spitbrook Rd.        Mailstop: ZKO3-2/W17
Nashua, NH 03062-9987    (603)881-2970, DTN:381-2970
+--------------------------------------------------------------------+
 

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

       reply	other threads:[~1996-12-16 18:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <199612152221.RAA06013@churchy.gnu.ai.mit.edu>
1996-12-16 18:44 ` Jerry Feldman [this message]
1996-12-16 19:21 Floating point exception Przemek Klosowski
  -- strict thread matches above, loose matches on Subject: below --
1996-12-15 22:21 Craig Burley
     [not found] <Pine.LNX.3.95.961215124644.26796Q-100000@sexpistols.dontknow.com>
1996-12-15 21:31 ` Paul B. Brown
1996-12-15 22:33 ` David R. McGown
1996-12-16 16:15 ` Richard Henderson
1996-12-15 12:54 Dan McGuirk
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