Page MenuHomeFreeBSD

libm: remainder: make sure x is zero
ClosedPublic

Authored by vexeduxr on Oct 10 2025, 12:57 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Nov 20, 3:39 PM
Unknown Object (File)
Tue, Nov 18, 11:26 PM
Unknown Object (File)
Fri, Nov 14, 8:47 AM
Unknown Object (File)
Thu, Nov 13, 6:23 AM
Unknown Object (File)
Sat, Nov 8, 12:07 AM
Unknown Object (File)
Thu, Nov 6, 8:24 AM
Unknown Object (File)
Tue, Nov 4, 4:56 PM
Unknown Object (File)
Tue, Nov 4, 2:17 AM
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.