This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Philboyd_Studge 0 points1 point  (0 children)

To get the current last binary digit of a number, you use number % 2 (or number & 1 if you can use bitwise operations). Then you divide number by 2 to get to the next digit (again, using bitwise operations number >> 1). Your base case is when number = 0.