C
C
Chemodan2282020-02-27 19:49:54
Algorithms
Chemodan228, 2020-02-27 19:49:54

How to take the remainder of a division using bitwise operations?

How to take the remainder of a division using bitwise operations?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Tsvetkov, 2020-02-28
@yellow79

If the divisor is a power of two, then the remainder of the division can be obtained by bit and but subtract one from the divisor. For example 4565567 % 8 = 4565567 & 7
If the divisor is not a power of two, then bit operations will not help you

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question