Page MenuHomeFreeBSD

libm: remainder: make sure x is zero
ClosedPublic

Authored by vexeduxr on Fri, Oct 10, 12:57 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Oct 10, 11:20 PM
Unknown Object (File)
Fri, Oct 10, 11:05 PM
Unknown Object (File)
Fri, Oct 10, 5:34 PM
Unknown Object (File)
Fri, Oct 10, 4:15 PM
Unknown Object (File)
Fri, Oct 10, 3:41 PM
Unknown Object (File)
Fri, Oct 10, 3:23 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.Sat, Oct 11, 10:19 AM
This revision was automatically updated to reflect the committed changes.