[Cfp-interest 3103] Re: Issue: frexp and double-double underflow

Hubert Tong hubert.reinterpretcast at gmail.com
Wed Apr 24 20:21:14 PDT 2024


On Wed, Apr 24, 2024 at 2:10 AM Fred J. Tydeman <tydeman at tybor.com> wrote:

> On Tue, 23 Apr 2024 22:56:50 -0600 (PDT) Fred J. Tydeman wrote:
> >
> >It is no different than frexp( DBL_TRUE_MIN*2.2, &exp);
> >which returns DBL_TRUE_MIN*1.1 (which is not underflow)
>
> Oops.  Wrong example.  That frexp() would return a value
> between 0.5 and 1.0.
>
> long double a = 1.L + DBL_TRUE_MIN;
> long double b;
>
> b = a / 2.L;  /* would return 0.5L + DBL_TRUE_MIN/2.L */
>

The value of `b` in your example is 0.5L (because 0.5L + DBL_TRUE_MIN/2.L
is not representable in the type).


>
> Which is not an underflow
>

I forgot to use scare quotes; silly me. Please move past the "underflow"
terminology (although underflow does occur with respect to the second
component of the double-double): The wording of frexp can be read as
insisting that the result is exact.

If an exact result is not required, then `x` and `p` should be defined in
terms of operations based on `value` (as opposed to now, where an operation
involving `x` and `p` is supposed to result in `value`). `value` in the
case presented is not the correctly-rounded result for any returned value
`x`.

A more subtle change would be to change `x` to not be in code font. I
believe being in code font implies a value representable by the
corresponding type.


>
>
> ---
> Fred J. Tydeman        Tydeman Consulting
> tydeman at tybor.com      Testing, numerics, programming
> +1 (702) 608-6093      Vice-chair of INCITS/C (ANSI "C")
> Sample C17+FPCE tests: http://www.tybor.com
> Savers sleep well, investors eat well, spenders work forever.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20240424/2201017f/attachment.htm>


More information about the Cfp-interest mailing list