Numbering Systems

advertisement
Numbering Systems
Decimal (base 10)
The decimal numbering system is the system we all use in our everyday work. It
consists of 10 digits (hence the name decimal). The digits, from smallest to largest
are:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9.
Now, any number can be broken down into columns. From right to left, the first
column is the 1's column, then the 10's column, then the 100's, then the 1000's, etc..
Let's look at the number 139:
Thousands
0
Hundreds
1
Tens
3
Ones
9
0 X 1000 = 0 (0 thousands)
1 X 100 = 100 (1 hundreds)
3 X 10 = 30 (3 tens)
9 X 1 = 9 (9 ones)
0+100 + 30 + 9 = 139
Binary (base 2)
Digital computers can only recognize two states, the presence of an electrical charge
or the absence of an electrical charge. In other words, ON or OFF.
The binary numbering system is ideal for representing these two states because it
consists of only two digits. The digits, from smallest to largest are:
0, 1.
0 represents the absence of an electrical charge or 'OFF'.
1 represents the presence of an electrical charge or 'ON'.
Once again, any number can be broken down into columns. Each column is a
placeholder. Using the binary numbering system, from right to left, the first column is
the 1's column, then the 2's column, then the 4's, then the 8's, then the 16's column,
then the 32's column, etc..
Let's look at the binary number 100010112:
One
hundred Sixtytwenty- fours
eights
1
0
Thirty- Sixteen
Eights
twos
s
0
0
Fours
1
0
Twos
1
Ones
1
1 X 128 = 128 (1 one hundred twenty-eights)
0 X 64 = 0 (0 sixty-fours)
0 X 32 = 0 (0 thirty-twos)
0 X 16 =0 (0 sixteens)
1 X 8 = 8 (1 eights)
0 X 4 = 0 (0 fours)
1 X 2 = 2 (1 twos)
1 X 1 = 1 (1 ones)
128 + 0 + 0 + 0 + 8 + 0 + 2 + 1 = 139
Thus, the binary number 10001011 is equal to 139 decimal.
A single digit (0 or 1) is called a 'bit' (binary digit).
The table above contains 8 bits. Each column can contain either a 1 or a 0 (because
there are only 2 digits in the binary numbering system). So, as you can see, it takes 8
bits to represent the decimal number 139.
Make sense?
If you don't understand it this far, go back over it until you do, or get some help.
Any character that you type (including spaces), and any character you can see on your
screen, takes 8 bits for your computer to produce. Eight bits grouped together are
called a 'byte'. A byte is the real building block of computer information. This can
form a single character. A character can be a number, letter, or symbol. The amount
of information a device can store is measured in bytes. Because of this, most numbers
and sizes reported by the computer are evenly divisible by 8.
Multiple bytes grouped together are often called a 'word'.
8 bits = 1 byte
1024 bytes = 1 kilobyte (KB)
1024 kilobytes = 1 megabyte (MB) (1,048,576 characters or bytes)
1024 megabytes = 1 gigabyte (GB)
These numbers are often rounded off for ease of calculation.
You might see 1 megabyte represented as a million bytes (1,000,000 characters), or
1000 kilobytes.
Converting Binary to Decimal
To convert from binary to decimal, multiply the 1s in a binary number by their
position value, then sum the products.
In the previous pages, we converted the binary number 10001011 to its decimal
equivalent using this technique.
Now try converting the binary number 10100111 to decimal.
Converting Decimal to Binary
A decimal number can be converted easily into an equivalent number of any base by
using the division/remainder technique.
Lets convert the decimal number 139 to binary:
2)139
Remainders
2) 69
1
2) 34
1
2) 17
0
2) 8
1
2) 4
0
2) 2
0
2) 1
0
0
1
To obtain the binary equivalent we read the remainders from the bottom up ie.
The binary equivalent of the decimal number 139 is 100010112
Now try converting the decimal number 166 to binary.
Hexadecimal (base 16)
The hexadecimal numbering system consists of sixteen digits. The digits, from
smallest to largest are:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
Once again, any number can be broken down into columns. Each column is a
placeholder. Using the hexadecimal numbering system, from right to left, the first
column is the 1's column, then the 16's column, then the 256's, then the 4096's, then
the 65536's column, etc. Because you multiply the number in each previous column
by 16, you can see that the numbers get very large very quickly.
Here's the hexadecimal number 8Bh:
65536
4096
256
16
8
1
B
0 X 65536 = 0 (0 sixty-five thousand five hundred thirty-sixes)
0 X 4096 = 0 (0 four thousand ninety-sixes)
8 X 16 = 128
11 X 1 = 11
0 + 0 + 128 + 11 = 139
Hexadecimal 8Bh = Decimal 139
Hexadecimal numbers are followed by a lowercase 'h' to designate them as hex.
Converting Binary to Hexadecimal
A single hexadecimal digit can represent any 4 bit binary number.
To convert binary to hexadecimal break the binary number into groups of 4 bits.
To convert 10001011, break into 2 groups of 4 bits, [1000][1011].
Use the chart below to find Hex numbers that match the groups of four bits.
Decimal Hex Binary
0
0 0000
1
1 0001
2
2 0010
3
3 0011
4
4 0100
5
5 0101
6
6 0110
7
7 0111
8
8 1000
9
9 1001
10
A 1010
11
B 1011
12
C 1100
13
D 1101
14
E 1110
15
F 1111
[1000] = 8h
[1011] = Bh
Binary = 10001011
Hexadecimal equivalent = 8Bh
One thing to keep in mind is that if you have a binary number like10 (2 decimal), you
can add zeros to the left to make it a full 4 bit number. eg. 0010
Now try converting the binary number 1100111 to hexadecimal.
If you don't understand it this far, go back over it until you do, or get some help.
Converting Decimal to Hexadecimal
Lets convert the decimal number 139 to hexadecimal:
16)139
Remainders
16) 8
B
0
8
Thus the hexadecimal equivalent of the decimal number 139 is 8Bh.
Now try converting the decimal number 166 to hexadecimal.
Converting Hexadecimal to Binary
To convert hex numbers into binary, we perform the grouping procedure for
converting binary to hex in reverse.
OK, lets try the number 8Bh:
From the chart on the previous page, 8h = [1000] Bh = [1011].
The binary equivalent is 100010011.
Now try converting the hexadecimal number 67h to binary.
Converting Hexadecimal to Decimal
To convert from binary to decimal, multiply each digit in a hexadecimal number by its
position value, then sum the products.
In the previous pages, we converted the hexadecimal number 8B to its decimal
equivalent using this technique.
Now try converting the hexadecimal number 6Dh to decimal.
Decimal, Binary and Hexadecimal Values
Digit Values
Decimal 100,000
Binary 512 256
Hexidecimal
10,000
128
65,536
1,000
64
32
4,096
100
16
256
10
8
4
16
1
2
1
1
Binary, Decimal and Hexadecimal Assignment
Convert the following numbers to binary
Dec
25
163
255
Hex
1A
C3
101
Convert the following numbers to decimal
Bin
10011000
11000111
110110110
Hex
1F
A5
1B6
Convert the following numbers to hexadecimal
Bin
1110
110110
110101111011
Dec
35
154
287
Binary & Hexidecimal - Review
1. One gigabyte is equal to ______________ .
1024 kilobytes
1024 megabytes
1024 bytes
8 bits
2. The decimal number 64 can be represented by which binary number?
00100000
10100000
01000000
11000010
3. What is the largest decimal number that can be represented using an 8-bit binary
number?
255
1024
256
4096
4. The binary number 00001100 can be represented by which hexidecimal number?
Ch
Dh
4Ch
A1h
5. True or False? The binary number 1101 is equal to 13 decimal.
True
False
6. The decimal number 15 is equal to the hexidecimal number Fh. What is the
hexidecimal equivalent of decimal 16?
Gh
1h
1Fh
10h
7. True or False? Hexidecimal numbers are always followed by a lowercase 'h' to
designate them as hex.
True
False
Download