diff options
| author | Ahmad Khalifa <vexeduxr@FreeBSD.org> | 2025-10-10 09:30:52 +0000 |
|---|---|---|
| committer | Ahmad Khalifa <vexeduxr@FreeBSD.org> | 2025-10-11 10:13:19 +0000 |
| commit | 25cca51ed294890d20a3c0290814cd26875db686 (patch) | |
| tree | b0edd3b45933b4b4f3b48cf4568da1cd70cb982a | |
| parent | 474ae083b1e19588c1bc2974082d2810ef9dc7f9 (diff) | |
libm: remainder: make sure x is zero
Make sure the entirety of x is zero before flipping the sign bit.
Otherwise the sign would be wrong for small values of x when x is
negative and |n*y| > |x|
Reported by: alfredo
PR: 251091
Reviewed by: kargl
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D53023
| -rw-r--r-- | lib/msun/src/e_remainder.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/msun/src/e_remainder.c b/lib/msun/src/e_remainder.c index a5fb7141d01a..cc6cd320073e 100644 --- a/lib/msun/src/e_remainder.c +++ b/lib/msun/src/e_remainder.c @@ -64,8 +64,8 @@ remainder(double x, double p) if(x>=p_half) x -= p; } } - GET_HIGH_WORD(hx,x); - if ((hx&0x7fffffff)==0) hx = 0; + EXTRACT_WORDS(hx, lx, x); + if (((hx&0x7fffffff)|lx) == 0) hx = 0; SET_HIGH_WORD(x,hx^sx); return x; } |
