comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: Interrupt "Get"
Date: 1998/05/21
Date: 1998-05-21T00:00:00+00:00	[thread overview]
Message-ID: <dewar.895802716@merv> (raw)
In-Reply-To: dewar.895755793@merv


Matthew said

<<Are you taking about a floating point divide or a fixed point divide?  They
are very different!

I'm confused by your answer, because a fixed point divide returns universal
fixed. How does one get a divide by zero exception, since 1) we've proven z
is in fact not zero, and 2) the universal fixed result has infinate range?
>>

Now we are carrying legalisms to the point of absurdity. The description
in the RM that the result is universal fixed is for semantic description
purposes only, it has nothing at all to do with the actual code, which
obviously does not produce a universal fixed result.

Matthew, you seem to think that the code actually reflects the RM, i.e.
that you first do a universal fixed division, and then a subtype conversion.
A little thought will show you that this is entirely impractical, and that
of course in practice, the generated code involves scaling operations and
multiplications and divisions that are *equivalent to* to the result of
first doing a universal fixed division and then doing the subtype conversion.

I guess that's what is confusing you here!!!!

In fact the comment about division by zero is exactly right, thankyou Simon
for pointing this out. It is not immediately obvious that this is the case
(this case cannot arise for example for normal integer division except in
very peculiar cases).

But consider, let's use decimal, it's easier

we want to divide 5.15 by 3.00

the representations are 515 and 300, but of course we cannot compute
the result as

   result = 515/300 * 100 

since that would lose precision. Instead we compute

   result = (100 * 515) / 300

Now in general this scaling means the numerator is double length, and it
can definitely occur that the most significant word of this double length
result is greater than the dividend, which is the condition for integer
overflow.

So, it is quite true that if we have a positive scale, which is the normal
case, as in the above (scale here = number of digits after point), then
we can get zero divide even with a non-zero divisor.

The test therefore is not simply a comparison with zero, but a comparison
for an excessively small value, and that is as easy a test to do!





  reply	other threads:[~1998-05-21  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-05-20  0:00 Interrupt "Get" John Slavich
1998-05-21  0:00 ` Robert Dewar
1998-05-21  0:00   ` Robert Dewar [this message]
1998-05-21  0:00   ` John Slavich
     [not found] ` <%1N81.460$ja.2197141@newsread.com>
1998-05-21  0:00   ` Robert Dewar
1998-05-22  0:00     ` Michael F Brenner
  -- strict thread matches above, loose matches on Subject: below --
1998-05-28  0:00 Joseph Altea
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox