data representation the binary number system. binary the binary number system is a means of...
TRANSCRIPT
![Page 1: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/1.jpg)
Data Representation
The Binary Number System
![Page 2: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/2.jpg)
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.
![Page 3: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/3.jpg)
Positional Notation
In the Decimal system each column of a number represents a power of 10.
103 102 101 100
1000 100 10 1
![Page 4: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/4.jpg)
Positional Notation
In the Binary system each column of a number represents a power of 2.
23 22 21 20
8 4 2 1
![Page 5: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/5.jpg)
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.
![Page 6: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/6.jpg)
Natural Numbers
Consider the pattern:
10010101
To calculate the Decimal equivalent of this number, multiply the each digit by the value of the column and sum the products.
![Page 7: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/7.jpg)
Natural Numbers
27 26 25 24 23 22 21 20
![Page 8: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/8.jpg)
Natural Numbers
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
![Page 9: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/9.jpg)
Natural Numbers
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1 1 0 0 1 0 1 0 1
![Page 10: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/10.jpg)
Natural Numbers
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1 1 0 0 1 0 1 0 1128 + 0 + 0 +16 +0 +4 + 0 + 1
![Page 11: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/11.jpg)
Natural Numbers
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1 1 0 0 1 0 1 0 1128 + 0 + 0 +16 +0 +4 + 0 + 1
=149
![Page 12: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/12.jpg)
Natural Numbers
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1 1 1 1 1 1 1 1 1128 +64 +32 +16 +8 +4 + 2 + 1
=255
This is the largest Unsigned value that can be stored in 8 bits.
How many patterns are there?
![Page 13: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/13.jpg)
Natural Numbers
Conversion from Decimal to Binary uses the same technique, in reverse.
Consider the value 73.
In Decimal, this is 7 units of 10, plus 3 units of 1.
![Page 14: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/14.jpg)
Natural Numbers
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
![Page 15: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/15.jpg)
Natural Numbers
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
![Page 16: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/16.jpg)
Natural Numbers
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
0 1
![Page 17: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/17.jpg)
Natural Numbers
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
0 1 0 0 1
![Page 18: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/18.jpg)
Natural Numbers
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
0 1 0 0 1 0 0 1
![Page 19: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/19.jpg)
Integer Storage
• To store integers, half the combinations are used to represent negative values.
• The Most Significant Bit is used to represent the sign.
• Which value of the sign bit (0 or 1) will represent a negative number?
![Page 20: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/20.jpg)
2’s Complement Notation(examples in 8 bits to save space)
• The notation system that uses 1 to represent negative values.
• Fixed length notation system.• Zero is the first non-negative value:
00000000
• The pattern immediately before zero is -111111111
• The largest value is stored as 01111111• The smallest value is stored as 10000000
![Page 21: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/21.jpg)
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.
![Page 22: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/22.jpg)
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 the complement of a number another technique is needed.
![Page 23: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/23.jpg)
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, first find the representation of 5:
00000101Then “flip the bits” and add 1.
11111010 + 111111011
![Page 24: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/24.jpg)
Arithmetic in 2’s Complement(remember it’s a fixed length system)
00 + 00 = 00
00 + 01 = 01
01 + 00 = 01
01 + 01 = 10
-1 in 2’s complement 11111111
+ 1 in 2’s complement + 00000001
0 discard the carry bit 1 00000000
![Page 25: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/25.jpg)
Fractions
• A radix separates the integer part from the fraction part of a number.
101.101• Columns to the right of the radix have
negative powers of 2.
![Page 26: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/26.jpg)
Fractions
22 21 20 . 2-1 2-2 2-3
![Page 27: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/27.jpg)
Fractions
22 21 20 . 2-1 2-2 2-3
4 2 1 . ½ ¼ ⅛
![Page 28: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/28.jpg)
Fractions
22 21 20 . 2-1 2-2 2-3
4 2 1 . ½ ¼ ⅛
1 0 1 . 1 0 1
![Page 29: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/29.jpg)
Fractions
22 21 20 . 2-1 2-2 2-3
4 2 1 . ½ ¼ ⅛
1 0 1 . 1 0 1
4 + 1 + ½ + ⅛
![Page 30: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/30.jpg)
Fractions
22 21 20 . 2-1 2-2 2-3
4 2 1 . ½ ¼ ⅛
1 0 1 . 1 0 1
4 + 1 + ½ + ⅛
5⅝
![Page 31: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/31.jpg)
Scientific Notation
Very large and very small numbers are often represented such that their order 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
![Page 32: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/32.jpg)
Scientific Notation
An electron's mass is about0.00000000000000000000000000000091093826 kg.
In scientific notation, this is written9.1093826×10−31 kg.
The Earth's mass is about5,973,600,000,000,000,000,000,000 kg.
In scientific notation, this is written5.9736×1024 kg.
![Page 33: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/33.jpg)
E Notation
To allow values like this to be expressed on calculators and early terminals
× 10b
was replaced by Eb
So 9.1093826×10−31
becomes 9.1093826E−31And 5.9736×1024
becomes 5.9736E+24
![Page 34: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/34.jpg)
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.
![Page 35: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/35.jpg)
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
![Page 36: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/36.jpg)
Excess Notation (examples are in 8 bits to save space)
• The notation system that uses 0 to represent negative values.
• Fixed length notation system.• Zero is the first non-negative value:
10000000
• The pattern immediately before zero is -101111111
• The largest value is stored as 11111111• The smallest value is stored as 00000000
![Page 37: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/37.jpg)
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.
![Page 38: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/38.jpg)
An example in 8 bits
If the following pattern stores a floating point value, what is it?
01101001
![Page 39: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/39.jpg)
An example in 8 bits
If the following pattern stores a floating point value, what is it?
01101001Separate it into its components:
![Page 40: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/40.jpg)
An example in 8 bits
If the following pattern stores a floating point value, what is it?
01101001Separate it into its components:
signexponentmantissa
![Page 41: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/41.jpg)
An example in 8 bits
If the following pattern stores a floating point value, what is it?
0 110 1001Separate it into its components:
signexponentmantissa
![Page 42: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/42.jpg)
An example in 8 bits
0 110 1001A sign bit of 0 means the number is…?
![Page 43: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/43.jpg)
An example in 8 bits
0 110 1001A sign bit of 0 means the number is positive.
110 in Excess Notation converts to …?
![Page 44: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/44.jpg)
An example in 8 bits
0 110 1001A sign bit of 0 means the number is positive.
110 in Excess Notation converts to +2.
Place the radix in the mantissa …
![Page 45: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/45.jpg)
An example in 8 bits
0 110 1001A 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 …
![Page 46: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/46.jpg)
An example in 8 bits
0 110 1001A 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 …
+ .1001 * 22
![Page 47: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/47.jpg)
An example in 8 bits
+ .1001 * 22
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.
+ 10.01
= 2¼
![Page 48: Data Representation The Binary Number System. Binary The binary number system is a means of representing quantities using only 2 digits: 0 and 1. Like](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56649dda5503460f94acff76/html5/thumbnails/48.jpg)
Normal Form
• The first bit of the mantissa must be 1 to prevent multiple representations of the same value.
0 100 1000 0 .1000 .1000
0 101 0100 1 .0100 .1000
0 110 0010 2 .0010 .1000
0 111 0001 3 .0001 .1000