Page MenuHomeFreeBSD

libm: remainder: make sure x is zero
ClosedPublic

Authored by vexeduxr on Oct 10 2025, 12:57 PM.
Tags
None
Referenced Files
F144436827: D53023.id163926.diff
Sun, Feb 8, 10:42 AM
F144374924: D53023.id164012.diff
Sun, Feb 8, 3:09 AM
Unknown Object (File)
Fri, Jan 30, 11:04 PM
Unknown Object (File)
Sat, Jan 24, 9:22 PM
Unknown Object (File)
Dec 26 2025, 2:49 AM
Unknown Object (File)
Dec 12 2025, 10:08 AM
Unknown Object (File)
Dec 11 2025, 8:21 AM
Unknown Object (File)
Dec 6 2025, 1:30 PM
Subscribers
None

Details

Summary

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 it is
negative and |n*y| > |x|

PR: 251091
MFC after: 3 days

Test Plan

This fixes the "rem3" test on powerpc64. It should also fix it on the rest of the architectures, but I haven't tested them.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

vexeduxr created this revision.

Ask kargl@ for explicit feedback and approval of the patch.

Will do. I tried to add him to the review before uploading the patch but couldn't find an account.

Will do. I tried to add him to the review before uploading the patch but couldn't find an account.

I don't think he has one; I'd suggest mailing him with the patch attached, but you can include a link to this review as well.

On Sat Oct 11, 2025 at 2:26 AM +0300, Steve Kargl wrote:

I do not have a phabricator account. That method to
review patches came after I stopped committing.

I did look at your patch, and do believe that it
is the correct fix. If you compare to remainderf(),
you'll see that the float version considers the
entire significand. I also checked remainderl().
It calls remquol() and it's implementation is
much different than the float and double versions.

This revision was not accepted when it landed; it landed in state Needs Review.Oct 11 2025, 10:19 AM
This revision was automatically updated to reflect the committed changes.