Number Systems

Definition

Put definition of generic base n

Popular Bases

Binary

Binary, or base 2, is the most commonly used number system in computers. The base 2 system only uses the digits, 0 and 1. Each digit in binary represents an extra power of two starting from the rightmost digit. For example the binary number 1101 can be expressed as (1*23) + (1*22) + (0*21) + (1*20).

Converting from Decimal to Binary

The fastest and most efficient way to convert from decimal to binary is by dividing by 2 and keeping track of the remainder. We stop when the quotient = 0. Then read the numbers stating from the bottom to get the binary number.

For example, to convert 156 from decimal to binary we do:

156 / 2 = 78 r = 0
78 / 2 = 39 r = 0
39 / 2 = 19 r = 1
19 / 2 = 9 r = 1
9 / 2 = 4 r = 1
4 / 2 = 2 r = 0
2 / 2 = 1 r = 0
1 / 2 = 0 r = 1

Thus by reading the numbers starting from the bottom we get, 10011100

Hexadecimal

Hexadecimal or base 16 is commonly used because of the less space it takes up. A hexadecimal number consists of the digits 0-9 and A-F to represent the values 10-15. This works in the same way as binary but instead of incrementing in powers of 2 it increments in powers of 16.

Example

The hexadecimal number A5B can be represented as (10*162) + (5*161) + (11*160) which is 2651 in decimal.

Converting from Binary to Hexadecimal

You can group 4 digits in binary as 1 digit in hexadecimal because 16 is 2^^4.

Example

To convert 100111000100 to hexadecimal we group in fours starting from the right to convert to hexadecimal.

Visual

screen-capture-4.png
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License