ISSUE 273

Add Proposal  Add Analysis  Edit Class, Environment, or Release
Number 273
Category errata
Synopsis LRM does not specify result of real division by 0
State open
Class errata-discuss
Arrival-DateJan 25 2003
Originator Shalom.Bresticker@motorola.com
Release 2001b: 4.
Environment
Description

The LRM says that result of division by 0 is x.
But this appears to refer to integer division.

The case of real division by 0 should be specified.
There are two cases: regular division by 0.0 and 0.0/0.0 .

Also, the sentence that division by 0 results in x
should be clarified to say that it refers to integer division.

Fix
Audit-Trail

From: "Brad Pierce" <Brad.Pierce@synopsys.com>
To: <etf-bugs@boyd.com>
Cc:
Subject: RE: errata/273: LRM does not specify result of real division by 0
Date: Sat, 25 Jan 2003 11:18:17 -0800

>The case of real division by 0 should be specified.
>There are two cases: regular division by 0.0 and 0.0/0.0 .

In floating-point arithmetic, the regular division would
be an Inf of the appropriate sign and the 0.0/0.0 would be
a NaN of the appropriate sign.

-- Brad



From: Shalom.Bresticker@motorola.com
To: Brad Pierce <Brad.Pierce@synopsys.com>
Cc: etf-bugs@boyd.com
Subject: RE: errata/273: LRM does not specify result of real division by 0
Date: Sun, 26 Jan 2003 05:19:00 +0200 (IST)

That is in fact what Verilog-XL produces.

Shalom

> >The case of real division by 0 should be specified.
> >There are two cases: regular division by 0.0 and 0.0/0.0 .
>
> In floating-point arithmetic, the regular division would
> be an Inf of the appropriate sign and the 0.0/0.0 would be
> a NaN of the appropriate sign.


From: Steven Sharp <sharp@cadence.com>
To: etf-bugs@boyd.com
Cc:
Subject: RE: errata/273: LRM does not specify result of real division by 0
Date: Tue, 28 Jan 2003 20:09:12 -0500 (EST)

The behavior of floating point division is set by IEEE Std 754 and the
fact that the floating point unit that this code executes on implements
IEEE floating point.

Steven Sharp
sharp@cadence.com


From: Shalom Bresticker <Shalom.Bresticker@motorola.com>
To: Steven Sharp <sharp@cadence.com>
Cc: etf-bugs@boyd.com
Subject: Re: errata/273: LRM does not specify result of real division by 0
Date: Wed, 29 Jan 2003 08:35:44 +0200

> The behavior of floating point division is set by IEEE Std 754 and the
> fact that the floating point unit that this code executes on implements
> IEEE floating point.

The LRM references IEEE 754 only with respect to floating point representation,
but not with respect to floating point arithmetic.

Also, you can not assume that the processor is 100% IEEE 754-compliant.
I have known processors that were not.

Also, some conversion questions that come to mind:

- How is Infinity (+ or -) converted to an integer?
- How is NaN converted to an integer?
- How is a negative number converted to an unsigned integer?


From: Steven Sharp <sharp@cadence.com>
To: etf-bugs@boyd.com
Cc:
Subject: Re: errata/273: LRM does not specify result of real division by 0
Date: Wed, 29 Jan 2003 21:38:19 -0500 (EST)

>The LRM references IEEE 754 only with respect to floating point representation,
>but not with respect to floating point arithmetic.
>
>Also, you can not assume that the processor is 100% IEEE 754-compliant.
>I have known processors that were not.

That is a valid point. I have known such processors also, including the x86.

But this argues against the LRM specifying these things. The only
practical way for the software to do floating point calculations is to
use the hardware it is running on. If the behavior of that hardware for
exception cases is not going to be consistent across platforms, then the
LRM should not try to specify it.

>Also, some conversion questions that come to mind:
>
>- How is Infinity (+ or -) converted to an integer?
>- How is NaN converted to an integer?

However the floating point unit does it. These cases just aren't worth
any special treatment by the software.

>- How is a negative number converted to an unsigned integer?

This is actually specified, in the first paragraph of 4.1.6.

Steven Sharp
sharp@cadence.com


From: Shalom.Bresticker@motorola.com
To: Steven Sharp <sharp@cadence.com>
Cc: etf-bugs@boyd.com
Subject: Re: errata/273: LRM does not specify result of real division by 0
Date: Thu, 30 Jan 2003 05:47:14 +0200 (IST)

> >The LRM references IEEE 754 only with respect to floating point representation,
> >but not with respect to floating point arithmetic.
> >
> >Also, you can not assume that the processor is 100% IEEE 754-compliant.
> >I have known processors that were not.
>
> That is a valid point. I have known such processors also, including the x86.
>
> But this argues against the LRM specifying these things. The only
> practical way for the software to do floating point calculations is to
> use the hardware it is running on. If the behavior of that hardware for
> exception cases is not going to be consistent across platforms, then the
> LRM should not try to specify it.

Then the LRM should say it is undefined.
I meant that the LRM should say something about the case.

>
> >Also, some conversion questions that come to mind:
> >
> >- How is Infinity (+ or -) converted to an integer?
> >- How is NaN converted to an integer?
>
> However the floating point unit does it. These cases just aren't worth
> any special treatment by the software.

As above.
>
> >- How is a negative number converted to an unsigned integer?
>
> This is actually specified, in the first paragraph of 4.1.6.

I saw that.
I submit that for the conversion of a real to an unsigned reg, 4.1.6 is not
clear enough, especially since 3.9.2 says that "Real numbers shall be converted
to integers by rounding the real number to the nearest integer". For the case of
a negative real to an unsigned reg, I might interpret that the nearest integer
is 0.

Shalom



From: Gordon Vreugdenhil <gvreugde@Synopsys.COM>
To: Shalom.Bresticker@motorola.com
Cc: etf-bugs@boyd.com
Subject: Re: errata/273: LRM does not specify result of real division by 0
Date: Thu, 30 Jan 2003 07:48:52 -0800

Shalom.Bresticker@motorola.com wrote:
>
> Precedence: bulk
>
> The following reply was made to PR errata/273; it has been noted by GNATS.
>
> From: Shalom.Bresticker@motorola.com
> To: Steven Sharp <sharp@cadence.com>
> Cc: etf-bugs@boyd.com
> Subject: Re: errata/273: LRM does not specify result of real division by 0
> Date: Thu, 30 Jan 2003 05:47:14 +0200 (IST)
>
> > >The LRM references IEEE 754 only with respect to floating point representation,
> > >but not with respect to floating point arithmetic.
> > >
> > >Also, you can not assume that the processor is 100% IEEE 754-compliant.
> > >I have known processors that were not.
> >
> > That is a valid point. I have known such processors also, including the x86.
> >
> > But this argues against the LRM specifying these things. The only
> > practical way for the software to do floating point calculations is to
> > use the hardware it is running on. If the behavior of that hardware for
> > exception cases is not going to be consistent across platforms, then the
> > LRM should not try to specify it.
>
> Then the LRM should say it is undefined.
> I meant that the LRM should say something about the case.


I disagree. If the LRM says "754-compliant" that is a sufficient
statement. I'd rather not try to either fix someone else's standard
or try to be explicit about incorrect implementations of 754.
There are some very subtle issues that can arise; I recall when I
was doing some AMS implementation (former job) that we ran into
a situation where a processor was using internal ops at a higher
precision than normal and that impacted some low-order bits in our
results. It would be a huge waste of time (in my opinion) to attempt
to deal with any and all ambiguities, interpretations, etc.

The expectation is that simulators will use underlying 754 compliant
hardware. If a poor/incorrect/different implementation causes problems,
the user should buy different hardware and complain to the manufacturer.

Gord.

> >
> > >Also, some conversion questions that come to mind:
> > >
> > >- How is Infinity (+ or -) converted to an integer?
> > >- How is NaN converted to an integer?
> >
> > However the floating point unit does it. These cases just aren't worth
> > any special treatment by the software.
>
> As above.
> >
> > >- How is a negative number converted to an unsigned integer?
> >
> > This is actually specified, in the first paragraph of 4.1.6.
>
> I saw that.
> I submit that for the conversion of a real to an unsigned reg, 4.1.6 is not
> clear enough, especially since 3.9.2 says that "Real numbers shall be converted
> to integers by rounding the real number to the nearest integer". For the case of
> a negative real to an unsigned reg, I might interpret that the nearest integer
> is 0.
>
> Shalom
>
>

--
----------------------------------------------------------------------
Gord Vreugdenhil gvreugde@synopsys.com
Staff Engineer, VCS (Verification Tech. Group) (503) 547-6054
Synopsys Inc., Beaverton OR

From: Shalom Bresticker <Shalom.Bresticker@motorola.com>
To: Gordon Vreugdenhil <gvreugde@Synopsys.COM>
Cc: etf-bugs@boyd.com
Subject: Re: errata/273: LRM does not specify result of real division by 0
Date: Thu, 30 Jan 2003 17:52:20 +0200

Gord, I repeat:

> The LRM references IEEE 754 only with respect to floating point representation,
> but not with respect to floating point arithmetic.


From: Steven Sharp <sharp@cadence.com>
To: etf-bugs@boyd.com
Cc:
Subject: Re: errata/273: LRM does not specify result of real division by 0
Date: Thu, 30 Jan 2003 13:30:29 -0500 (EST)

>From: Gordon Vreugdenhil <gvreugde@synopsys.com>

> I disagree. If the LRM says "754-compliant" that is a sufficient
> statement.

Shalom is correct that the LRM does not specify that the arithmetic will
be 754-compliant, only the representation. And if I had any need to
support Verilog on a platform that didn't use IEEE floating point, I would
object to the LRM saying that much.

Verilog implementations need to use whatever floating point support is
available on the platform, and there should be nothing in the LRM to
restrict it.

The only issue here is that the LRM specifically gives the result of
4-state integer division by zero, without making it entirely clear that
it doesn't apply to reals.

Steven Sharp
sharp@cadence.com


From: Steven Sharp <sharp@cadence.com>
To: Cc: etf-bugs@boyd.com
Subject: Re: errata/273: LRM does not specify result of real division by 0
Date: Thu, 30 Jan 2003 14:08:08 -0500 (EST)

>Then the LRM should say it is undefined.
>I meant that the LRM should say something about the case.

I don't have a problem with that, though I'm not sure it is necesary.


>> >- How is a negative number converted to an unsigned integer?
>>
>> This is actually specified, in the first paragraph of 4.1.6.
>
>I saw that.
>I submit that for the conversion of a real to an unsigned reg, 4.1.6 is not
>clear enough, especially since 3.9.2 says that "Real numbers shall be converted
>to integers by rounding the real number to the nearest integer". For the case
of
>a negative real to an unsigned reg, I might interpret that the nearest integer
>is 0.

Sorry, for some reason I assumed you were talking about integers here,
rather than a negative real. My mistake.

I consider this issue to be more important than the previous ones in this
erratum.

Conversion of reals to unsigned integers is actually done by converting
to the nearest signed integer, and then "converting" that to unsigned.

Steven Sharp
sharp@cadence.com

Unformatted


Hosted by Boyd Technology