    Next: Memory Up: Computer Representation of Numbers Previous: Computer Representation of Numbers   Contents

# Binary numbers

In the decimal system, the number 107.625 means

Such a number is the sum of terms of the form {a digit times a different power of 10} - we say that 10 is the basis of the decimal system. There are 10 digits (0,...,9).

All computers today use the binary system. This has obvious hardware advantages, since the only digits in this system are 0 and 1. In the binary system the number is represented as the sum of terms of the form {a digit times a different power of 2}. For example,

Arithmetic operations in the binary system are performed similarly as in the decimal system; since there are only 2 digits, 1+1=10.

Decimal to binary conversion. For the integer part, we divide by 2 repeatedly (using integer division); the remainders are the successive digits of the number in base 2, from least to most significant.

For the fractional part, multiply the number by 2; take away the integer part, and multiply the fractional part of the result by 2, and so on; the sequence of integer parts are the digits of the base 2 number, from most to least significant.

Octal representation. A binary number can be easily represented in base 8. Partition the number into groups of 3 binary digits (), from decimal point to the right and to the left (add zeros if needed). Then, replace each group by its octal equivalent.

Hexadecimal representation. To represent a binary number in base 16 proceed as above, but now partition the number into groups of 4 binary digits (). The base 16 digits are 0,...,9,A=10,...,F=15.

1. Convert the following binary numbers to decimal, octal and hexa: 1001101101.0011, 11011.111001;
2. Convert the following hexa numbers to both decimal and binary: 1AD.CF, D4E5.35A;
3. Convert the following decimal numbers to both binary and hexa: 6752.8756, 4687.4231.    Next: Memory Up: Computer Representation of Numbers Previous: Computer Representation of Numbers   Contents