Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Binary Number System

Similar presentations


Presentation on theme: "The Binary Number System"— Presentation transcript:

1 The Binary Number System
Data Representation The Binary Number System

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 In the Decimal system each column of a number represents a power of 10. 103 102 101 100 1000 10 1

4 Positional Notation In the Binary system each column of a number represents a power of 2. 23 22 21 20 8 4 2 1

5 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.

6 Natural Numbers 10010101 Consider the pattern:
To calculate the Decimal equivalent of this number, multiply the each digit by the value of the column and sum the products.

7 Natural Numbers

8 Natural Numbers

9 Natural Numbers

10 Natural Numbers

11 Natural Numbers =149

12 How many patterns are there?
Natural Numbers =255 This is the largest Unsigned value that can be stored in 8 bits. How many patterns are there?

13 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.

14 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

15 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

16 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

17 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

18 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

19 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?

20 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: The pattern immediately before zero is -1 The largest value is stored as The smallest value is stored as

21 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.

22 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.

23 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: Then “flip the bits” and add 1. + 1

24 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

25 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.

26 Fractions 22 21 20 . 2-1 2-2 2-3

27 Fractions 22 21 20 . 2-1 2-2 2-3 4 2 1

28 Fractions 22 21 20 . 2-1 2-2 2-3 4 2 1

29 Fractions 22 21 20 . 2-1 2-2 2-3 4 2 1 +

30 Fractions 22 21 20 . 2-1 2-2 2-3 4 2 1 + 5⅝

31 Scientific Notation a × 10b 1 ≤ |a| < 10
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

32 Scientific Notation An electron's mass is about
 kg. In scientific notation, this is written ×10−31 kg. The Earth's mass is about 5,973,600,000,000,000,000,000,000 kg. 5.9736×1024 kg.

33 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

34 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.

35 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

36 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: The pattern immediately before zero is -1 The largest value is stored as The smallest value is stored as

37 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.

38 An example in 8 bits If the following pattern stores a floating point value, what is it?

39 An example in 8 bits If the following pattern stores a floating point value, what is it? Separate it into its components:

40 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

41 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

42 An example in 8 bits A sign bit of 0 means the number is…?

43 An example in 8 bits A sign bit of 0 means the number is positive. 110 in Excess Notation converts to …?

44 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 …

45 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 …

46 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

47 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¼

48 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


Download ppt "The Binary Number System"

Similar presentations


Ads by Google