From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <9612161844.AA11677@sauron.zk3.dec.com> Date: Mon, 16 Dec 96 13:44:23 -0500 From: Jerry Feldman Subject: Re: Floating point exception In-Reply-To: <199612152221.RAA06013@churchy.gnu.ai.mit.edu> > >Anyone know why this program causes a floating point exception on the > >Alpha? > > > >#include > > > >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