You can convert an integer decimal number to a binary


Binary is a numer system used by computers. It consists of only two digits, 0 and 1, which represent off and on. In decimal numbers, there are ten digits, 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. When you write 247 in decimal, it represents (2 x 10^2) + (4 x 10^1) + (7 x 10^0). The same is true in binary, only the base number is ***** instead of ten. Thus, 1101 is (1 x 2^3) + (1 x 2^2) + (0 x 2^1) + (1 x 2^0).

You can convert an integer decimal number to a binary number by a recurrsive algorithm.

Binary(X)

Simple cases: If X is 0, the binary of X is 0. If X is 1, the binary of X is 1

Complex case: Print the binary of (X / 2). Print the binary of (X % 2). (Note: % means the remainder of a division)

Test your function. The binary of 12 is 1100. The binary of 3 is 11.

Hint: Do NOT use floating point numbers. This algorithm only works with integer numbers.

Solution Preview :

Prepared by a verified Expert
Assembly Language: You can convert an integer decimal number to a binary
Reference No:- TGS01719147

Now Priced at $40 (50% Discount)

Recommended (95%)

Rated (4.7/5)