Implement C23 pown [committed]
Segher Boessenkool
segher@kernel.crashing.org
Wed Jun 4 18:32:58 GMT 2025
On Wed, Jun 04, 2025 at 03:50:53PM +0000, Joseph Myers wrote:
> On Tue, 3 Jun 2025, Segher Boessenkool wrote:
>
> > The commit message clearly says this implementation isd correct for
> > IEEE float only. And indeed it is not for double-double, which is very
> > much not IEEE.
> >
> > Maybe these tests should require IEEE float? The implementation does,
> > after all!
>
> I don't know how you're reading the commit message as saying this is only
> correct for IEEE formats.
"The underlying implementation uses __ieee754_pow functions". Yeah that
does not literallky say that it only works correctly for IEEE float, but
it does suggest that, and all evidence we have point in the same
direction.
> I might be more concerned about correctness of
> the compoundn implementation for IBM long double (although no issues have
> been reported), but not pown where, again, the implementation reduces to
>
> #if M_MANT_DIG >= LLONG_WIDTH - 1
> ret = M_SUF (__ieee754_pow) (x, y);
> #else
>
> and if there's a problem, either it's a bug in powl, or a bug in libgcc
> converting y from long long to long double (which should be exact) outside
> round-to-nearest mode, but not a bug in this implementation.
pown (-inf, MAXINT) returns +inf, and some things that should be finite
return a NaN, and probably some other interesting infelicities as well.
If such things do work correctly for IEEE float, that makes it seem this
code is really only written to be correct for IEEEE (which is hard
enough of course!)
Segher
More information about the Libc-alpha
mailing list