Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XMVectorRound doesn't match roundf #38

Closed
walbourn opened this issue Oct 24, 2016 · 4 comments
Closed

XMVectorRound doesn't match roundf #38

walbourn opened this issue Oct 24, 2016 · 4 comments
Assignees
Labels

Comments

@walbourn
Copy link
Member

walbourn commented Oct 24, 2016

The mm_round_ps intrinsic performs ties to even (a.k.a. banker's rounding): round(0.5) = 0.0 , round(1.5) = 2.0 .

The C99 roundf function performs ties away from zero: round(0.5) = 1.0 , round(1.5) = 2.0 .

@walbourn walbourn added the bug label Oct 24, 2016
@walbourn
Copy link
Member Author

walbourn commented Oct 24, 2016

Per the Intel SSE4 guide, _mm_round_ps by itself can match ceil, floor, trunc, rint, and nearbyint. You need a little more to get it to match roundf.

@walbourn
Copy link
Member Author

ARM v8's FRINTN also performs banker's rounding, which I'll be using for the ARM64 implementation.

@walbourn
Copy link
Member Author

walbourn commented Oct 25, 2016

The bug here is actually that the NO_INTRINSICS path on VS 2013+ should not be using roundf because all the other implementations are using round-to-nearest (even). It might be nice to offer an alternative round function that uses the roundf half-way round away from zero rules, but such a round wouldn't be a single instruction for SSE4 or ARM-NEON--filed as new issue.

@walbourn walbourn changed the title XMVectorRound with /arch:AVX doesn't match roundf XMVectorRound doesn't match roundf Oct 25, 2016
@walbourn walbourn self-assigned this Oct 25, 2016
@walbourn
Copy link
Member Author

Fixed for DirectXMath 3.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant