git: 439909c48b0e - stable/14 - libm: remainder: make sure x is zero
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 14 Oct 2025 14:16:17 UTC
The branch stable/14 has been updated by vexeduxr:
URL: https://cgit.FreeBSD.org/src/commit/?id=439909c48b0e8b0e8dda03b9a359b73dcabb546e
commit 439909c48b0e8b0e8dda03b9a359b73dcabb546e
Author: Ahmad Khalifa <vexeduxr@FreeBSD.org>
AuthorDate: 2025-10-10 09:30:52 +0000
Commit: Ahmad Khalifa <vexeduxr@FreeBSD.org>
CommitDate: 2025-10-14 14:00:19 +0000
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
(cherry picked from commit 25cca51ed294890d20a3c0290814cd26875db686)
---
lib/msun/src/e_remainder.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/msun/src/e_remainder.c b/lib/msun/src/e_remainder.c
index 406f12c14c2f..057da0e3d990 100644
--- a/lib/msun/src/e_remainder.c
+++ b/lib/msun/src/e_remainder.c
@@ -65,8 +65,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;
}