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

Implement Oshrximm #9

Closed
ymherklotz opened this issue Nov 3, 2020 · 1 comment
Closed

Implement Oshrximm #9

ymherklotz opened this issue Nov 3, 2020 · 1 comment

Comments

@ymherklotz
Copy link
Owner

ymherklotz commented Nov 3, 2020

Currently Oshrximm is not implemented, as it needs to be implemented with a division.

One reason for the mismatch between division and shift is shown below:

-11 / (1 << 1) = -5
-11 >>> 1      = -6

Therefore it will always be more efficient to use unsigned division by a constant compared to signed division by a constant.

Maybe there is a more efficient implementation of this special case.

@ymherklotz
Copy link
Owner Author

ymherklotz commented Nov 3, 2020

The following might be the correct, efficient implementation of Oshrximm (x / (2 ^ y)):

q = $signed(x) < 0 ? - ((-x) >> y) : x >> y;

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

No branches or pull requests

1 participant