Download presentation
1
Data Representation Number Systems
2
Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like other number systems it’s based on Positional Notation.
3
Positional Notation
The Decimal system is based on the number of digits we have. Positional Notation allows us to count past 10 by organizing numeric digits in columns. Each column of a number represents a power of the base. The base is 10. The exponent is the order of magnitude for the column.
4
Positional Notation 103 102 101 100 10001 1001 11 The exponent is the order of magnitude for the column. The Least Significant digit is in the right-most column. The Most Significant digit is in the left-most column.
5
Positional Notation 103 102 101 100 10001 1001 11 The base is 10.
6
Positional Notation 103 102 101 100 10001 1001 11 The magnitude of the column is base exponent
7
Positional Notation =27916 Consider a number like the one above. How many does it represent?
8
Positional Notation =27916 The size of a number is determined by multiplying the magnitude of the column by the digit in the column and summing the products.
9
Positional Notation =27916 The columns are labelled with their exponents.
10
Positional Notation =27916 The base of the system is 10.
11
Positional Notation =27916 The magnitude of the column is base exponent
12
Positional Notation *2 *7 *9 *1 *6 =27916 Multiply the magnitude of the column by the digit in the column.
13
Positional Notation *2 *7 *9 *1 *6 27 thousand, 9 hundred, sixteen Sum the products.
14
Positional Notation In Binary, the columns have the expected exponents 23 22 21 20 81 41 11
15
Positional Notation In Binary, the columns have the expected exponents but the base of the system is 2. 23 22 21 20 81 41 11
16
Positional Notation In Binary, the columns have the expected exponents but the base of the system is 2. So the column magnitudes are powers of 2. 23 22 21 20 81 41 11
17
Binary Rather than referring to each of the numbers as a binary digit, we shorten the term to bit. To facilitate addressing, binary values are typically stored in units of 8 bits, which is called a byte. Large values occupy multiple bytes.
18
Natural Numbers in Binary
Consider the pattern: To calculate the Decimal equivalent of this number, multiply each digit by the value of the column and sum the products.
19
Natural Numbers in Binary
20
Natural Numbers in Binary
21
Natural Numbers in Binary
22
Natural Numbers in Binary
23
Natural Numbers in Binary
=149
24
Natural Numbers in Binary
=255 This is the largest unsigned value that can be stored in 8 bits. How many different patterns are there?
25
Natural Numbers in Binary
Conversion from Decimal to Binary uses the same technique, in reverse. Consider the value 73. This is 7 units of 10, plus 3 units of 1.
26
Natural Numbers in Binary
We need to express the value in terms of powers of 2. 27 26 25 24 23 22 21 20 128 64 32 16 8 4 2 1
27
Natural Numbers in Binary
What is the largest power of 2 that is included in 73? 27 26 25 24 23 22 21 20 128 64 32 16 8 4 2 1
28
Natural Numbers in Binary
64 is the largest power of 2 that is included in 73, so a 1 is needed in that position 27 26 25 24 23 22 21 20 128 64 32 16 8 4 2 1
29
Natural Numbers in Binary
Subtracting 64 from 73 leaves 9, which cannot include 32, or 16, but does include 8. 27 26 25 24 23 22 21 20 128 64 32 16 8 4 2 1
30
Natural Numbers in Binary
Subtracting 8 from 9 leaves 1, which cannot include 4, or 2, but does include 1. 27 26 25 24 23 22 21 20 128 64 32 16 8 4 2 1
31
Natural Numbers in Binary
So the 8 bit binary representation of 73 is:
32
Arithmetic in Binary
33
Binary Addition A “Rule of Addition” is a statement of the form: 3 + 5 = 8 How many such rules are there in Decimal?
34
Binary Addition “Rules of Addition”
10 digits can appear as the first addend, and 10 can appear as the second, so Decimal has 10 * 10, or 100 “Rules of Addition”
35
0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 10 Binary Addition
In Binary there are 4 “Rules of Addition”: 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 10
36
Binary Addition To add any 2 binary numbers, simply apply the rules on each column, starting at the right – just like Decimal.
37
Binary Addition To add any 2 binary numbers, simply apply the rules on each column, starting at the right – just like Decimal.
38
Binary Addition To add any 2 binary numbers, simply apply the rules on each column, starting at the right – just like Decimal.
39
Binary Addition To add any 2 binary numbers, simply apply the rules on each column, starting at the right – just like Decimal.
40
Binary Addition To add any 2 binary numbers, simply apply the rules on each column, starting at the right – just like Decimal.
41
Binary Addition To add any 2 binary numbers, simply apply the rules on each column, starting at the right – just like Decimal.
42
Binary Addition To add any 2 binary numbers, simply apply the rules on each column, starting at the right – just like Decimal.
43
Binary Addition To add any 2 binary numbers, simply apply the rules on each column, starting at the right – just like Decimal.
44
Binary Addition To add any 2 binary numbers, simply apply the rules on each column, starting at the right – just like Decimal.
45
Binary Addition To add any 2 binary numbers, simply apply the rules on each column, starting at the right – just like Decimal.
46
Binary Multiplication
Any multiplication can be re-expressed as a series of additions. For example, 7 * 3 (seven times three) is simply the sum of 3 sevens. 7 * 3 = Since we already know how to perform addition, binary multiplication becomes easy.
47
Binary Multiplication
7 0111 * 3 + 0111 1110 10101
48
Binary Multiplication
7 0111 * 3 + 0111 1110 10101
49
Binary Multiplication
7 0111 * 3 + 0111 1110 10101
50
Binary Multiplication
7 0111 * 3 + 0111 1110 10101
51
Binary Multiplication
7 0111 * 3 + 0111 1110 10101
52
Binary Multiplication
The multiplication of large values will take many such additions, but the machine doesn’t mind. Even so, we look for faster more efficient techniques, and there is one available. It’s based on the Algebraic property called Distribution.
53
Binary Multiplication
The Distribution Property can be expressed this way: a * (x + y) = a * x + a * y Any number can be expressed as the sum of other numbers: 106 * 37 = 106 * (30 + 7) = (106 * 30) + (106 * 7)
54
Binary Multiplication
The other insight necessary to optimize multiplication regards multiplying a number by its base. In Decimal, multiplying anything by 10 is easy - simply shift the digits to the left, and pad with a zero. 975 * 10 = 9750
55
Binary Multiplication
This is true in any number system. In Binary, for example: 001 represents 1 010 represents 2 100 represents 4
56
Binary Multiplication
This is true in any number system. In Binary, for example: 001 represents 1 010 represents 2 100 represents 4 Each shift/pad doubles the value.
57
Binary Multiplication
Now reconsider this problem: 106 * 37 = ? Expressed as this distribution: 106 * ( ) = 106 * * * 1
58
Binary Multiplication
Now reconsider this problem: 106 * 37 = ? Expressed as this distribution: 106 * ( ) = 106 * * * 1
59
Binary Multiplication
Now reconsider this problem: 106 * 37 = ? Expressed as this distribution: 106 * ( ) = 106 * * * 1
60
Binary Multiplication
? = 106 * * * 1 32 = (25) 4 = (22) 1 = (20) by substitution… ? = 106 * * * 20
61
Binary Multiplication
? = 106 * * * 1 32 = (25) 4 = (22) 1 = (20) by substitution… ? = 106 * * * 20
62
Binary Multiplication
? = 106 * * * 1 32 = (25) 4 = (22) 1 = (20) by substitution… ? = 106 * * * 20
63
Binary Multiplication
? = 106 * * * 1 32 = (25) 4 = (22) 1 = (20) by substitution… ? = 106 * * * 20
64
Binary Multiplication
? = 106 * * * 1 32 = (25) 4 = (22) 1 = (20) by substitution… ? = 106 * * * 20
65
Binary Multiplication
? = 106 * * * 20 This term can be simplified.
66
Binary Multiplication
? = 106 * * * 20 106
67
Binary Multiplication
? = 106 * * * 20 106 converts to
68
Binary Multiplication
? = 106 * * * 20 106 106 * 22
69
Binary Multiplication
? = 106 * * * 20 106 106 * 22 shift 2
70
Binary Multiplication
? = 106 * * * 20 106 106 * 22 shift 2
71
Binary Multiplication
? = 106 * * * 20 106 106 * 25
72
Binary Multiplication
? = 106 * * * 20 106 106 * 25 shift 5
73
Binary Multiplication
? = 106 * * * 20 106 106 * 25 shift 5
74
Binary Multiplication
? = 106 * * * 20 106 106 * 22 106 * 25 ====================================
75
Binary Multiplication
? = 106 * * * 20 106 106 * 22 106 * 25 ==================================== Sum
76
Integers
77
Integer Storage To store integers, the Most Significant Bit is used to represent the sign. Thus, half the combinations can be used to represent negative values. Which value of the sign bit (0 or 1) will represent a negative number?
78
2’s Complement Notation (examples in 8 bits to save space)
Fixed length notation system. Uses 1 to represent negative values. The largest non-negative value: The smallest non-negative value: The largest negative value is: The smallest negative value is:
79
2’s Complement Notation
Note that the representations of non-negative integers in 2’s Complement look the same as they do for Natural numbers. However, negative values look VERY different than we might expect.
80
2’s Complement Notation
Complementary numbers sum to 0. Decimal is a Signed Magnitude system so complements have the same magnitude but different signs: 5 and -5, for example. 2’s Complement is a Fixed Length system. There are no signs, so to find a number’s complement, another technique is needed.
81
2’s Complement Notation
One such technique is to simply change each bit to its opposite, and then add 1.
82
2’s Complement Notation
One such technique is to simply change each bit to its opposite, and then add 1. To find the 2’s complement notation for -5:
83
2’s Complement Notation
One such technique is to simply change each bit to its opposite, and then add 1. To find the 2’s complement notation for -5: Represent +5 in fixed length
84
2’s Complement Notation
One such technique is to simply change each bit to its opposite, and then add 1. To find the 2’s complement notation for -5: Represent +5 in fixed length
85
2’s Complement Notation
One such technique is to simply change each bit to its opposite, and then add 1. To find the 2’s complement notation for -5: Represent +5 in fixed length “flip the bits” (1 → 0, 0 → 1)
86
2’s Complement Notation
One such technique is to simply change each bit to its opposite, and then add 1. To find the 2’s complement notation for -5: Represent +5 in fixed length “flip the bits” (1 → 0, 0 → 1)
87
2’s Complement Notation
One such technique is to simply change each bit to its opposite, and then add 1. To find the 2’s complement notation for -5: Represent +5 in fixed length “flip the bits” (1 → 0, 0 → 1) add 1 to the new pattern +1
88
2’s Complement Notation
One such technique is to simply change each bit to its opposite, and then add 1. To find the 2’s complement notation for -5: Represent +5 in fixed length “flip the bits” (1 → 0, 0 → 1) add 1 to the new pattern +1 to produce -5
89
2’s Complement Notation
Complementary numbers sum to 0. So if to +5 we add -5 we should get discard the carry bit
90
Arithmetic in 2’s Complement (remember it’s a fixed length system)
= 00 = 01 = 01 = 10 -1 in 2’s complement + 1 + discard the carry bit 1
91
Arithmetic in 2’s Complement
The ability to represent negative values in Binary means that the Addition operation can be used to effect subtraction. The expression 7 – 3 can be alternatively represented as (+7) + (-3). With the 4 “Rules of Binary Addition” and 2’s Complement Notation, addition becomes subtraction.
92
Arithmetic in 2’s Complement (remember it’s a fixed length system)
(+7) - (+3)
93
Arithmetic in 2’s Complement (remember it’s a fixed length system)
(+7) - (+3)
94
Arithmetic in 2’s Complement (remember it’s a fixed length system)
(+7) - (+3)
95
Arithmetic in 2’s Complement (remember it’s a fixed length system)
(+7) - (+3)
96
Arithmetic in 2’s Complement (remember it’s a fixed length system)
(+7) - (+3) +1
97
Arithmetic in 2’s Complement (remember it’s a fixed length system)
(+7) +1 + (-3)
98
Arithmetic in 2’s Complement (remember it’s a fixed length system)
(+7) + (-3) +1 discard the carry bit
99
Arithmetic in 2’s Complement (remember it’s a fixed length system)
(+7) + (-3) +1 discard the carry bit
100
Division
101
Division Just as multiplication can be expressed as a series of additions, division can be seen as a series of subtractions. 21 ÷ 7 asks how many times 7 can be subtracted from 21.
102
Division In Binary, subtraction is done by adding a negative value…
So division is the repeated addition of a negative value.
103
Division 21 ÷ 7 = ?
104
Division 21 ÷ 7 = ?
105
Division 21 ÷ 7 = ?
106
Division 21 ÷ 7 = ?
107
Division 21 ÷ 7 = ?
108
Division 21 ÷ 7 = ?
109
Division 21 ÷ 7 = ? keep the carry bits
110
Division 21 ÷ 7 = ?
111
Division 21 ÷ 7 = ?
112
Division 21 ÷ 7 = ?
113
Division 21 ÷ 7 = ?
114
Division 21 ÷ 7 = ? quotient remainder
115
Division This is integer division. It produces a quotient, and
a remainder. Of course, the remainder won’t always be 0!
116
Excess Notation The other way to represent Integers.
117
Excess Notation (examples are in 8 bits to save space)
Fixed length notation system. Uses 0 to represent negative values. The largest non-negative value: The smallest non-negative value: The largest negative value is: The smallest negative value is:
118
Excess Notation (examples are in 8 bits to save space)
To better understand how binary patterns unpack under the 3 integer notations, let’s look at an example. Consider the pattern Show the value it represent if it’s: an unsigned integer signed integer, 2’s Complement Notation signed integer, Excess Notation
119
Excess Notation (examples are in 8 bits to save space)
The pattern ( ) has 2 parts:
120
Excess Notation (examples are in 8 bits to save space)
The pattern ( ) has 2 parts: the MSB
121
Excess Notation (examples are in 8 bits to save space)
The pattern ( ) has 2 parts: the MSB the rest
122
Excess Notation (examples are in 8 bits to save space)
The pattern ( ) has 2 parts: the MSB the rest Let’s look at “the rest”:
123
Excess Notation (examples are in 8 bits to save space)
The pattern ( ) has 2 parts: the MSB the rest Let’s look at “the rest”: As a Natural number, this is , or 57.
124
Excess Notation (examples are in 8 bits to save space)
The pattern ( ) is, therefore, 57 greater than – regardless of the meaning of the MSB.
125
Excess Notation (examples are in 8 bits to save space)
As an unsigned integer, is 128
126
Excess Notation (examples are in 8 bits to save space)
As an unsigned integer, is 128 In 2’s Complement, is the smallest, negative value…
127
Excess Notation (examples are in 8 bits to save space)
As an unsigned integer, is 128 In 2’s Complement, is the smallest, negative value… In Excess Notation, is the smallest, non-negative value…
128
Excess Notation (examples are in 8 bits to save space)
So the pattern is 57 greater than: 128 if it’s natural (57+128=185) -128 if it’s 2’s Complement (57-128= -71) 0 if it’s Excess (57+0= 57)
129
Binary Fractions
130
Fractions A radix separates the integer part from the fraction part of a number. Columns to the right of the radix have negative powers of 2.
131
Fractions 22 21 20 . 2-1 2-2 2-3
132
Fractions 22 21 20 . 2-1 2-2 2-3 4 2 1 ⅛
133
Fractions 22 21 20 . 2-1 2-2 2-3 4 2 1 ⅛
134
Fractions 22 21 20 . 2-1 2-2 2-3 4 2 1 ⅛ +
135
Fractions 22 21 20 . 2-1 2-2 2-3 4 2 1 ⅛ + 5⅝
136
Fractions Another way to assess the fraction: ½ ¼ ⅛ Just as this is 5
137
Fractions Another way to assess the fraction: ½ ¼ ⅛ Just as this is so is this!
138
Fractions Another way to assess the fraction: ½ ¼ ⅛ Just as this is so is this Except it’s not 5 ones. It’s 5 eighths.
139
Fractions Another way to assess the fraction: ½ ¼ ⅛ Just as this is so is this Except it’s not 5 ones. It’s 5 eighths.
140
Fractions But there’s no dot (.) in Binary!
We need to explore a method for storing fractions without inventing another symbol.
141
Scientific Notation a × 10b 1 ≤ |a| < 10
Very large and very small numbers are often represented such that their orders of magnitude can be compared. The basic concept is an exponential notation using powers of 10. a × 10b Where b is an integer, and a is a real number such that: 1 ≤ |a| < 10
142
Scientific Notation - examples
An electron's mass is about kg. In scientific notation, this is written: ×10−31 kg.
143
Scientific Notation - examples
The Earth's mass is about 5,973,600,000,000,000,000,000,000 kg. In scientific notation, this is written: 5.9736×1024 kg.
144
E Notation To allow values like this to be expressed on calculators and early terminals × 10b was replaced by Eb So ×10−31 becomes E−31 And ×1024 becomes E+24
145
E Notation The ‘a’ part of the number is called the mantissa or significand. The ‘Eb’ part is called the exponent. Since exponents could also be negative they would typically have a sign as well.
146
Floating Point Storage
In floating point notation the bit pattern is divided into 3 components: Sign – 1 bit (0 for +, 1 for -) Exponent – stored in Excess notation Mantissa – must begin with 1
147
Mantissa Assumes a radix point immediately left of the first digit.
The exponent will determine how far and in which direction to move the radix.
148
An example in 8 bits If the following pattern stores a floating point value, what is it?
149
An example in 8 bits If the following pattern stores a floating point value, what is it? Separate it into its components:
150
An example in 8 bits If the following pattern stores a floating point value, what is it? Separate it into its components: sign exponent mantissa
151
An example in 8 bits If the following pattern stores a floating point value, what is it? Separate it into its components: sign exponent mantissa
152
An example in 8 bits A sign bit of 0 means the number is…?
153
An example in 8 bits A sign bit of 0 means the number is positive. 110 in Excess Notation converts to …?
154
An example in 8 bits A sign bit of 0 means the number is positive. 110 in Excess Notation converts to +2. Place the radix in the mantissa …
155
An example in 8 bits A sign bit of 0 means the number is positive. 110 in Excess Notation converts to +2. Place the radix in the mantissa .1001 Put it all together …
156
An example in 8 bits A sign bit of 0 means the number is positive. 110 in Excess Notation converts to +2. Place the radix in the mantissa .1001 Put it all together … * 22
157
An example in 8 bits + .1001 * 22 + 10.01 = 2¼
Multiplying a binary number by 2 shifts the bits left (moves the radix to the right) one position. So this exponent tells us to shift the radix 2 positions right. = 2¼
158
Normal Form The first bit of the mantissa must be 1 to prevent multiple representations of the same value. .1000 1 .0100 2 .0010 3 .0001
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.