answersLogoWhite

0

I am assuming you mean positive integer in decimal notation.

Here is an algorithm that lists the binary representation backwards, that is

from right to left, least significant digit first.

N is the number decimal number

While N > 0

print N rem 2 // output the remainder

N = N/2 // replace N by n divided by 2

end loop

Example: trace for n = 101

n output

101

50 1

25 0

12 1

6 0

3 0

1 1 -- Last one had 0; 3%2 is 1

0 1

Output would be 1010011 ---- from left to right would be 1100101

Check: 64 + 32 + 0 + 0 + 4 + 1 = 101.

User Avatar

Wiki User

15y ago

Still curious? Ask our experts.

Chat with our AI personalities

BlakeBlake
As your older brother, I've been where you are—maybe not exactly, but close enough.
Chat with Blake
CoachCoach
Success isn't just about winning—it's about vision, patience, and playing the long game.
Chat with Coach
ProfessorProfessor
I will give you the most educated answer.
Chat with Professor

Add your answer:

Earn +20 pts
Q: Algorithm for finding binary representation of positive decimal integer?
Write your answer...
Submit
Still have questions?
magnify glass
imp