Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

fixed_point_t uses multiplication/division instead of arithmetic shift #3

Open
salkinium opened this issue Jan 6, 2016 · 0 comments

Comments

@salkinium
Copy link
Owner

For constexpr this doesn't really matter, however, arithmetic shift is probably faster.

There is a subtle difference between v >> s and v / (1 << s):

One important consequence of the arithmetic right shift is that it will round negative
numbers towards negative infinity while a division is always rounding towards zero. So
a right shift on negative numbers is not identical to a division.

Example: -3 / 2 = -1
-3 >> 1 = -2

(taken from this discussion on the topic)

So the eps and cmath rounding algorithms will have to be adapted.

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

No branches or pull requests

1 participant