[Cfp-interest 3311] Re: ERANGE question

Vincent Lefevre vincent at vinc17.net
Sat Oct 12 15:58:44 PDT 2024


On 2024-10-12 14:29:07 -0700, Jim Thomas wrote:
> On Oct 9, 2024, at 5:45 AM, Vincent Lefevre <vincent at vinc17.net> wrote:
> > "the representation with full precision in the specified type" implies
> > that the result is rounded. Otherwise I don't see how this can be
> > interpreted.
> > 
> > But I'm wondering why the word "full" is used.
> 
> This is intended to accommodate double-double formats that can

I now remember, but for the double-double format, you'll get
an infinity in such a case; see below.

> represent results with huge finite magnitude but not with the full
> precision of the type, e.g. if both parts of a double-double number
> are DBL_MAX. Such numbers are beyond the range of C model numbers.
> Such results are overflows, per definition above.

No, such numbers are not possible in a double-double format. From
the spec in GCC's libgcc/config/rs6000/ibm-ldouble-format file:

  Each long double is made up of two IEEE doubles.  The value of the
long double is the sum of the values of the two parts (except for
-0.0).  The most significant part is required to be the value of the
long double rounded to the nearest double, as specified by IEEE.  For
Inf values, the least significant part is required to be one of +0.0
or -0.0.  No other requirements are made; so, for example, 1.0 may be
represented as (1.0, +0.0) or (1.0, -0.0), and the low part of a NaN
is don't-care.

See the condition on the most significant part.

However, one can imagine other formats where there are "holes" in the
ordinary accuracy (a unum format can be such a case, BTW).

> > Ditto in 6.4.5.3p7
> > about floating literals of decimal floating type. Is this because
> > some representations are not normalized, thus are regarded as
> > having less precision?
> > 
> >> Should errno be set to ERANGE, even if x^y rounds to DBL_MAX?
> > 
> > In rounding to nearest, I would say no.
> > 
> > But for the directed rounding modes, the definition seems wrong.
> 
> Note that the definition includes “ordinary accuracy” (defined by
> the implementation). This is intended to cover IEEE 754 overflow
> with directed rounding (as well as no nearest).

Well, the definition is wrong. But I may not have the latest version.
The first thing is that in

  A floating result overflows if a finite result value with ordinary
  accuracy [...]

this does not say how "a floating result" relates to "a finite result
value with ordinary accuracy".

-- 
Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


More information about the Cfp-interest mailing list