Describe the algorithm in pseudo code for finding the binary representation of a positive decimal integer.
Your code should be placed in a code block
(math and equations should be done in Latex math symbols)
I am forward you mean positive whole number in mathematical notation.
Here is Associate in Nursing algorithmic program that lists the binary illustration 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 one -- Last one had 0; thirty two is one
0 1
Output would be 1010011 ---- from left to right would be
1100101
Check: 64 + 32 + 0 + 0 + 4 + 1 = 101.
Get Answers For Free
Most questions answered within 1 hours.