I don't think you can divide by 10 with bitwise operators. You can divide by 2, 4, 8, 16, etc with the %26gt;%26gt; (rotate right) operator though.
example:
int b, a = 200;
b = a %26gt;%26gt; 1; //divide by 2 b = 100
b = a %26gt;%26gt; 2; //divide by 4 b = 50
b = a %26gt;%26gt; 3; //divide by 8 b = 25
b = a %26gt;%26gt; 4; //divide by 16 b = 12
b = a %26gt;%26gt; 5; //divide by 32 b = 6
b = a %26gt;%26gt; 6; //divide by 64 b = 3
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment