[PATCH] math: Fix errno setting for narrowing sqrt functions on underflow [BZ #33393]
Osama Abdelkader
osama.abdelkader@gmail.com
Mon Oct 20 19:31:07 GMT 2025
On Mon, Oct 20, 2025 at 06:26:19PM +0000, Wilco Dijkstra wrote:
> Hi Osama,
>
> > Thanks for the feedback, that is actually my first contribution to glibc attempt,
> > will try to find something simpler.
>
> Yes it's unfortunate that errno is so problematic. I was thinking of suggesting the
> ilogb issue as a simpler one. However there are several target implementations
> that would need to be fixed too, and then there is the question what to do with
> targets that inline the function without setting errno...
>
> If you're looking for something small in terms of math, one option would be to
> look at rewriting some of the ancient math functions. There are many smallish
> functions that could be optimized by doing basic tricks. Eg. the frexp() fast path
> should be as trivial as:
>
> if (__glibc_likely ((ex - 1) < 0x7fe)
> {
> ex -= 1022;
> *eptr = ex;
> return asdouble (ix - ex << 53);
> }
>
> Cheers,
> Wilco
Hi Wilco,
Thanks for the suggestion, I'm going to do that.
Thanks,
Osama
More information about the Libc-alpha
mailing list