From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fc89c,7e35f49d4d9340ab X-Google-Attributes: gidfc89c,public X-Google-Thread: 1164f8,7e35f49d4d9340ab X-Google-Attributes: gid1164f8,public X-Google-Thread: 109fba,7e35f49d4d9340ab X-Google-Attributes: gid109fba,public From: "Michael C. Grant" Subject: Re: Division by zero crashes on DEC should be avoidable! Date: 1998/03/08 Message-ID: <6dvpck$edd@camel12.mindspring.com>#1/1 X-Deja-AN: 332115574 References: <34FF7719.41C6@ned.dem.csiro.au> <6dpdce$jsg@gap.cco.caltech.edu> <6dpuqm$2vk@camel21.mindspring.com> X-Server-Date: 9 Mar 1998 03:58:12 GMT X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4 Organization: MindSpring Enterprises Newsgroups: comp.sys.dec,comp.lang.c++,comp.unix.programmer You're quite correct. For a number of reasons, including pipelining issues, floating-point exceptions can significantly decrease the performance of a piece of computational code. And I don't want the processor to have to empty its floating-point pipeline just to tell me something that I already know. Interestingly, many pipelining issues reared their ugly head _after_ the IEEE floating-point standard was already established. In fact, if I remember correctly, certain Alpha processors purposefully violate certain more esoteric parts of the standard, in order to preserve the pipeline in exceptional circumstances. So unnecessary floating-point exceptions can _seriously_ compromise the performance of floating-point code. But so can writing a bunch of extra code to manually detect division by zero. No matter what, it is always important to fully understand the consequences of division by zero, etc. when writing numerical code. If your code considers a division by zero to be an exceptional occurrence, then I say that it's _your_ responsibility to throw an exception---and it's _your_ responsibility to document your code so that its users avoid that pitfall. Don't let the compiler do your work for you, because invariably it doesn't catch everything. Michael Pierre Asselin wrote in message ... >"Michael C. Grant" writes: > >>Folks, it really isn't very difficult to work with division by zero and >>infinities in computational code. In fact, it's a very useful idiom, and >>that's precisely the reason why the IEEE floating-point standards allow it. > >I think there's also a technical reason behind it. Something to do >with vector processors or long floating-point pipelines, and not >stalling them with an exception when an infinity or a NAN would do.