From: "Anthony W. Youngman" <thewolery@nospam.demon.co.uk>
Subject: Re: division by zero exceptions ?
Date: 1998/10/31 [thread overview]
Message-ID: <oLe+DbAf73O2EwFZ@thewolery.demon.co.uk> (raw)
In-Reply-To: 01be0482$6ebd1e60$45934b0c@default
Apologies for copying the previous poster and replying at the top :-(
Alpha was designed by DEC and copies VMS, which also has "infinity".
What on earth is wrong with a "divide by zero" returning "infinity" as
the answer? After all it is mathematically correct.
By all means make it an option whether to return infinity or an error,
but have you ever tried maths programming with a system that only
returns an error?
Code like "x = y / tan( z)" is a damn nightmare if it is legal and
probable that z might be pi/2. I wrote code to calculate distances on a
grid, and I reckon about half the code was devoted to trapping instances
where the two points I was checking shared the same lat or long, as this
would have triggered a divide by zero. It would have been so much easier
if my compiler supported infinity, because then a following calculation
would have divided by it and returned the answer I wanted (ie d(lat)=0)
without having to put code in to trap that as a special case.
In article <01be0482$6ebd1e60$45934b0c@default>, Shana Tackett
<sltackett@worldnet.att.net> writes
>The Alpha has much better exception handling than the PII. The PII is
>setting the register to INF upon division
>by zero and continues processing. To me the Alpha is correct. You have
>asked the processor to do something
>which does not make sense and it has reported an error. Whereas the PII has
>returned an answer which has to
>interpreted as being an invalid answer. A lot of sloppy mathematical code
>will run fine on an Intel chip producing
>a result which really has no meaning. This is not so on an Alpha. It is
>better to get no answer than an answer
>which is spurious and can be wrongly interpreted as correct. Hence write
>and develop your code on the alpha this way it
>will be thoroughly tested. There are instructions in AXP which allow you to
>specifiy a function to be called upon
>a floating point exception and have the function handle the error. So it is
>possible to get the same result, although
>I would not want to.
>
>This is one of the main reasons for complications for poorly written
>mathematics code to not be easily ported from
>Intel to Alpha.
>
>Conrad Sanderson <conrad@hive.me.gu.edu.au> wrote in article
><slrn737pv0.5bf.conrad@hive.me.gu.edu.au>...
>> running this C++ program on an Alpha:
>>
>> void main() {
>> float a = 10.0; float b = 0.0;
>> float c = a/b;
>> cout << "c = " << c << endl;
>> }
>>
>> causes "Floating exception Exit 136", while on Intel PII is says:
>> "c = Inf", which is the "correct" answer.
>>
>> Is there any way to make the Alpha do the same thing as PII ?
>> I know about linking with -mieee, but that makes programs run
>> too slow, so that is not a solution for me.
>>
>> I'm using egcs 1.1 without optimization for the above prog.
>>
>>
>> --
>> Conrad Sanderson - Microelectronic Signal Processing Laboratory
>> Griffith University, Queensland, Australia
>> http://spl.me.gu.edu.au [ under construction ]
>>
--
Anthony W. Youngman - wol at thewolery dot demon dot co dot uk
Trousers with a single hole in their waistband are topologically equivalent
to a doughnut. These sugarcoated trousers have yet to catch on at fast-food
outlets! (SuperStrings by F. David Peat)
If replying by e-mail please mail wol. Anything else may get missed amongst
the spam.
next prev parent reply other threads:[~1998-10-31 5:00 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-10-26 5:00 division by zero exceptions ? Conrad Sanderson
1998-10-26 5:00 ` Michal Jaegermann
1998-10-27 5:00 ` Remco Wouts
1998-10-28 5:00 ` Nils Faerber
1998-10-31 5:00 ` Shana Tackett
1998-10-30 5:00 ` James D. Freels
1998-10-31 5:00 ` Greg Lindahl
1998-10-31 5:00 ` Toon Moene
1998-10-31 5:00 ` Anthony W. Youngman
1998-11-01 5:00 ` Stefan Davids
1998-11-01 5:00 ` Bill Metzenthen
1998-11-01 5:00 ` Anthony W. Youngman
1998-11-02 5:00 ` Bill Metzenthen
1998-11-02 5:00 ` Conrad Sanderson
1998-11-02 5:00 ` Stefan Davids
1998-11-02 5:00 ` Michal Jaegermann
1998-11-03 5:00 ` rscanon
1998-10-31 5:00 ` Bill Metzenthen
1998-10-31 5:00 ` Anthony W. Youngman [this message]
1998-11-01 5:00 ` Greg Lindahl
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