[Cfp-interest 3228] Re: llogb()
Jim Thomas
jaswthomas at sbcglobal.net
Sun Aug 18 16:02:20 PDT 2024
> On Aug 14, 2024, at 7:06 PM, Fred J. Tydeman <tydeman at tybor.com> wrote:
>
> On Wed, 14 Aug 2024 15:42:44 -0700 Jerome Coonen wrote:
>>
>> Fred: investigate range error issue for llogb(), which differs from
>> ilogb()
>
> 7.12.7.10 The llogb functions
>
> In paragraph 2, Change
>
> If the correct value is outside the range of the return type, the
> numeric result is unspecified.
>
> to
>
> If the correct value is outside the range of the return type, the
> numeric result is unspecified and a domain error or range error may
> occur.
>
> Resaon
>
> This is to be consistent with ilogb. Also, Annex H adds extended
> floating-point types which could have exponent ranges that require
> more than 32 bits (the minimum width of long int).
Also, C (without Annex F) doesn’t place an upper limit for the size of the exponent for the standard floating types.
>
> Aside: I would like: and a domain error shall occur
> instead of what ilogb has.
> Depends upon what we are doing with "may occur".
So you would like two changes:
1. “may" to “shall”
It might be that errno is a legacy feature: implementations do what they have been doing and current users are adapted to that, and neither implementors nor users would benefit from a change. Hopefully new code is using floating-point exceptions instead of errno.
2. “domain error or range error" to "domain error"
Ugh. In C18 (and before), “a range error occurs if and only if the mathematical result of the function cannot be represented in an object of the specified type, due to extreme magnitude.” With this definition, a range error seems reasonable here, even though the result format is not a floating type and there is no overflow or underflow. In C23, "a range error occurs if and only if the result overflows or underflows, as defined below". An overflow requires returning the value of a HUGE_VAL macro which isn’t possible here. It appears the C23 definition is not compatible with the ilogb specification. This is not a problem for Annex F which requires a domain error, reported via an “invalid” floating-point exception, per ISO/IEC 60559.
- Jim Thomas
>
>
> ---
> 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.
>
> _______________________________________________
> Cfp-interest mailing list
> Cfp-interest at oakapple.net
> http://mailman.oakapple.net/mailman/listinfo/cfp-interest
More information about the Cfp-interest
mailing list