1.1.1 Number Representation

advertisement
1.1 Information
Representation
1.1.1 Number Representation
Learning Objectives
(a) show understanding of the basis of different number systems and
use the binary, denary and hexadecimal number system
(b) convert a number from one number system to another
(c) express a positive or negative integer in two’s complement form
(d) show understanding of, and be able to represent, character data in
its internal binary form depending on the character set used
(Candidates will not be expected to memorise any particular
character codes but must be familiar with ASCII and Unicode.
(e) express a denary number in Binary Coded Decimal (BCD) and vice
versa
Numbers
• Each number system is associated with a base
▫ The decimal number system is said to be of base 10
• A number in base r contains r digits 0,1,2,...,r-1
▫ Decimal (Base 10): 0,1,2,3,4,5,6,7,8,9
In addition to decimal, two other number systems are also
important: Binary and Hexadecimal
Number Systems
WHAT, more number systems?
Why do we need more number systems?
• Humans understand decimal
Check out my ten digits !
•
Digital electronics (computers) understand
binary
Number Systems
Why binary system?
• Computers are made of a series of switches
• Each switch has two states: ON or OFF
• Each state can be represented by a number – 1 for
“ON” and 0 for “OFF”
Number Systems
Hexadecimal
• Hexadecimal (base 16) number system are
used to represent binary data in a more
compact form.
Number Systems
Common Number Systems
• Denary aka Decimal System
(Base 10)
• (i.e. 0…9)
• Binary System (base 2)
• (i.e 1,0)
• Hexadecimal System (base 16)
• (i.e 0…9,A,B,C,D,E,F)
Denary to Binary Conversion – Example 1
Divide by two and use the remainder
(Method 1)
1. Divide the starting number by 2. If
it divides evenly, the binary digit is
0. If it does not - if there is a
remainder - the binary digit is 1.
2. Repeat the process with the
integer quotient until it becomes 0
3. Record the bits from bottom to
top.
Binary to Denary Conversion – Answer Check
1. Multiply each bit by
2 with
incrementing
exponent from 0
(from the left side)
until the last bit in
place (from the
right side).
2. Add up all the
products
26
25
24
23
22
21
20
Denary to Binary Conversion – Example 2
• Convert 122
(denary) to binary
Binary to Denary Conversion– Example 2
• Convert 122 (denary) to binary
Denary to Binary Conversion – Example 3
Take off the biggest 2n value you can (Method 2)
1. Remove the 2n numbers from the main number and
mark up the equivalent 2n column with a 1.
2. Work through the remainders until you reach zero.
Stop when you reach zero
3. Complete the final columns with 0s.
Denary to Binary Conversion – Example 3
Activity
• Online Game Activity
• Decimal to Binary Worksheet
Denary to Hexadecimal Conversion –
Example 1
Denary to Hexadecimal Conversion –
Example 2
• Convert 921 (denary to
hexadecimal)
Denary to Hexadecimal Conversion –
Example 3
• Convert 590 (denary to
hexadecimal)
• Remember that we
represent 10 . . 15 as A . . F
Hexadecimal to Denary Conversion –
Example 1
1. Multiply each digit by 16 with
incrementing exponent from 0
(from the left side) until the
last digit in place (from the
right side).
2. Add up all the products
This is similar to binary – denary
conversion but we use base 16
instead of base 2.
• Convert 1128(base 16) to
denary.
• Solution:
1 x 163 +1 x 162 + 2 x 161 + 8 x 160
4096 + 256 + 32
+8
= 4392
Hexadecimal to Denary Conversion –
Example 1
• Convert 1531 (base 16)
to Decimal
Hexadecimal to Denary Conversion –
Example 2
• Convert FA8(base 16) to
Decimal
Hexadecimal to Binary
• Technique
• Convert each hexadecimal digit to a 4bit equivalent binary representation
Number Systems
Example
10AF16 = ?2
1
0
0001
0000
A
F
1010
10AF16 = 00010000101011112
Number Systems
1111
Binary system complements
As the binary system has base r = 2. So the two types of complements for
the binary system are 2's complement and 1's complement.
1's complement
The 1's complement of a number is found by changing all 1's to 0's and all
0's to 1's. This is called as taking complement or 1's complement.
Example of 1's Complement is as follows.
2's complement
The 2's complement of binary number is obtained by adding 1 to the Least Significant Bit
(LSB) of 1's complement of the number.
2's complement = 1's complement + 1
Example of 2's Complement is as follows.
Two’s Complement
• Convert -28 in two’s
complement
• Get the binary value of +28 in 8
bits:
00011100
• Flip to get the one’s complement
11100011
• Add 1 to get the two’s
complement
11100011
+
1
11100100
-28 = 11100100
Binary Coded Decimal (BCD)
• BCD is a binary representation
which can be used for a positive
denary integer (0..9 only)
• Each digit of the denary is
represented in sequence with a
group of four binary digits
• Example: represent 859 in BCD
8
5
9
1000
0101
1001
859 denary = 100001011001 as
BCD
Binary Coded Decimal (BCD)
• Convert 372 denary into BCD
• Convert A4
• Example: represent 372 in BCD
3
7
2
0011
0111 0010
372 denary = 001101110010
as BCD
• Example: represent A4 in BCD
CANT BE DIRECTLY REPRESENTED
Binary Coded Decimal (BCD) Application
• Early computers stored date and
time values in the BIOS of the OS
using BCD
• Later game consoles like Atari
and Sony Playstation had used
BCD
• BCD is used in electronics too
like pocket calculators, digital
clocks
Written Activity
Download
Random flashcards
Radioactivity

30 Cards

African nomads

18 Cards

History of Europe

27 Cards

Create flashcards