Lecture 01 Number Conversion
Lecture 01 Number Conversion
Lecture 6
2
Transforming Data Into Information
■ Understands only two states either
On or Off
❑ Makes different patterns of 0s and 1s
■ Data vs Information
■ How Computers Represent Data
3
How Computer Represent Data
■ Number system
❑ Manner of Counting
❑ Several different number
systems exist
■ To Computer everything is
a number
❑ Alphabets, numbers,
punctuation marks, sound,
pictures, computer
instructions
❑ For example
■ “Here are some words.”
4
Decimal Numbers
■ Used by humans to count
■ Latin word deci mean 10
■ Also called Base 10
■ Have 10 distinct digits
❑ 0123456789
■ 10 is a two-digit number
■ Digits combine to make
larger numbers
5
Binary Number System
■ Switch has two states
❑ Off represents 0, On is 1
■ Latin bi means 2
■ Used by computers to
count
■ Two distinct digits, 0 and 1
❑ 0 and 1 combine to make
numbers
■ represent a quantity >1 it
uses two (or more) digits
■ Pattern repeats indefinitely
6
Data Representation
A computer circuit represents the 0 or the 1
electronically by the presence or absence
of an electrical charge
7
Comparison Base 2 to Base 16
8
Number Conversion
■ Decimal to Binary
■ Binary to Decimal
■ Decimal to Octal
■ Octal to Decimal
■ Decimal to Hexadecimal
■ Hexadecimal to Decimal
■ Binary to Octal
■ Octal to Binary
■ Binary to Hexadecimal
■ Hexadecimal to Binary
■ Octal to Hexadecimal
■ Hexadecimal to Octal
9
Decimal To Binary
■ 1
10
Decimal To Binary
■ (151)10 = (10010111)2
11
Binary to Decimal
12
Binary to Decimal
13
Binary to Decimal
■ 11100012 = 11310
14
Binary to Decimal
■ 111001111012 = 185310
■ 110110102 = 21810
15
Exercise Decimal to Binary
16
Decimal to Octal
■ 432110 = 103418
17
Octal to Decimal
18
Exercise Decimal to Octal
19
Exercise Octal to Decimal
■ 266018 =
■ 14228 =
20
Decimal to Hexadecimal
21
Decimal to Hexadecimal
22
Hexadecimal to Decimal
23
Comparison Base 2 to Base 16
24
Binary to Hexadecimal
25
Hexadecimal to Binary
26
Binary and Octal
27
Octal to Binary
28
Octal to Hexadecimal
29
Hexadecimal to Octal
30
Exercise Binary to Hexadecimal
■ (10110101010101)2 ■ (1100010010)2
31
Exercise Octal to Hexadecimal
■ (344)8 ■ (1422)8
32
Number System Program
■ Genius Maker
■ Free software
■ Use the number system
http://www.goldenkstar.com/number-system-school-software-maths.htm
33
Number System - Exercise
Decimal Binary Octal Hexadecimal
(786)10 (1100010010)2 (1422)8 (312)16
(555)10 (1000101011)2 (1053)8 (22B)16
(228)10 (11100100)2 (786)8 (786)16
(179)10 (10110011)2 (786)8 (786)16
(483)10 (111100011)2 (743)8 (1E3)16
(4012)10 (111110101100)2 (7643)8 (FAC)16
(4321)10 (1000011100001)2 (10341)8 (10E1)16
(1853)10 (11100111101)2 (3475)8 (73D)16
(9526)10 (1001010011011)2 (22466)8 (2536)16
(11605)10 (10110101010101)2 (26525)8 (2D55)16
(48879)10 (111111011101111)2 (137357)8 (BEEF)16
34
Boolean Algebra
■ Describes the relationship between the inputs
and outputs of a digital circuit
■ George Boole, an English Mathematician in
1854 proposed the basic principles of algebra
■ Uses Variables and operations
■ Boolean variable has only two possible values
❑ 0 or 1 or False or True
■ Basic Logical operations are
❑ AND, OR and NOT
35
Basic Logical Operations
■ AND operation
❑ yields true in case when both of its operands are
true
■ OR operation
❑ yields true in case when either or both of its
operands are true
■ NOT operation
❑ Used to invert the value of its operand
36
Logical Operations
■ Truth Table is a list of all possible input values
and the output for each input combination
38
Logical Circuit to Truth Table
39
Logical Circuit to Truth Table
40
Logical Circuit to Truth Table
41
Logical Circuit to Truth Table
42
Logical Circuit to Truth Table
43
Logical Circuit to Truth Table
44
Logical Circuit to Truth Table
45
Logical Circuit to Truth Table
46
Logical Circuit to Truth Table
47
Conversion (with Fractions)
And Floating point representation
48
Decimal to Binary (with Fractions)
■ (12.75)10 = (1100.11)2
49
Floating point representation
50
Binary to Decimal (with Fractions)
■ (10.011010101)2 = (2.416015625)10
51
Complements/ Negative Numbers
■ 1’s complement
■ Change all 1s to 0s and all 0s to 1s
1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1
52
Complements/ Negative Numbers
■ 2’s complement
■ Find 1’s complement and then add 1
1 0 1 0 1 0 1 0
1
1’s complement 0 1 0 1 0 1 0 1
Input bits
Adder Carry
Output bits (sum) In (add 1)
2’s complement 0 1 0 1 0 1 1 0
53
Bits and Bytes
■ Binary numbers are made of bits
■ Bit represents a switch
■ A byte is 8 bits
■ Byte represents one character
54
Bit and Byte
55
Text Codes
■ Converts letters, numbers, special symbols
into binary numbers
■ Standard codes necessary for data transfer
■ Same combinations of numbers to
represent the same individual pieces of data
■ Four most popular codes
❑ EBCDIC
❑ ASCII
❑ Extended ASCII
❑ Unicode
56
EBCDIC
■ Extended Binary Coded Decimal
Interchange Code
■ 8-bit code to represent 256 symbols
■ Still used in IBM mainframes and mid range
computers
■ Rarely used in PCs
57
EBCDIC
58
ASCII
■ American Standard Code for Information
Interchange
■ Most popular and widely used character set
■ Used to represent English symbols
■ 7-bit code to represent 128 characters
❑ From 0 to 127
❑ 33 are non-printing control characters (now mostly
obsolete)
❑ 95 printable characters including space (invisible
graphic character)
59
ASCII Codes
60
ASCII Code
61
Extended ASCII
■ 8-bit code that specifies the characters for
values from 128 to 255.
■ First 40 symbols represent pronunciation and
special punctuation symbol
❑ 128 to 167
■ Remaining are for graphics and other
symbols
62
Extended ASCII Code
63
Letter Conversion to Binary
64
Unicode
■ Unicode Worldwide Character Standard
provides up to 4-bytes—32 bits
■ Can represent more than 4 billion characters or
symbols
❑ 232 = 1,073,741,832
■ Enough for every unique character and symbol
in the world
❑ Chinese, Korean and Japanese Languages
■ Codes for special mathematical and scientific
symbols
■ First 256 characters are same as ASCII
■ Current version (Jan 2012) is 6.1
❑ Contains 110,181 characters from 100 different
languages and scripts
65
Binary Arithmetic
■ Similar to arithmetic in decimal number
system
■ Operations performed
❑ Addition
❑ Subtraction
❑ Multiplication
❑ Division
66
Binary Arithmetic
■ i
67
Binary Arithmetic
■ i
68
Summary
■ Number System
■ Decimal, Binary, Octal, Hexadecimal
■ Number conversion
■ Boolean Algebra
■ Logic Gate (AND, OR, NOT, NAND, NOR, XOR)
■ Conversion (Fractional Numbers)
■ Floating point numbers
■ Binary Arithmetic
■ Complements (1st and 2nd)
69
Recommended Websites
■ http://www.cdrummond.qc.ca/cegep/info
rmat/Professeurs/Alain/files/ascii.htm
■ http://www.lookuptables.com/ebcdic_sc
ancodes.php
■ http://math.comsci.us/radix/hexadecimal
.html
70