[Cfp-interest 3104] Re: [SC22WG14.25365] Issue: frexp and double-double underflow

Hubert Tong hubert.reinterpretcast at gmail.com
Thu Apr 25 22:49:52 PDT 2024


On Wed, Apr 24, 2024 at 11:21 PM Hubert Tong <
hubert.reinterpretcast at gmail.com> wrote:

> 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.
>

I suppose the "math" interpretation leads to a situation where
frexpl(2.L - DBL_TRUE_MIN)

can be read as calculating x (mathematically) as 1.L - 0.5*DBL_TRUE_MIN,
which would then round to a value of 1.L.

Technically, there is no specification issue because the input is not a
floating-point number under the model (has a value not represented by the
model); however, it may be helpful to specify that the range restriction is
upon the correctly-rounded result (if that is the intent).


>
>
>>
>>
>> ---
>> 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/20240426/680d2cc5/attachment.htm>


More information about the Cfp-interest mailing list