the binary number system

50
The Binary Number System Data Representation

Upload: clarke

Post on 08-Jan-2016

108 views

Category:

Documents


4 download

DESCRIPTION

The Binary Number System. Data Representation. What is a number?. What is a number?. A number is a unit of an abstract mathematical system subject to the laws of arithmetic. The Laws of Arithmetic. Succession Addition Multiplication. Number Categories. Natural (Whole) - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: The Binary Number System

The Binary Number System

Data Representation

Page 2: The Binary Number System

What is a number?

Page 3: The Binary Number System

What is a number?

A number is a unit of an abstract mathematical system subject to the laws of arithmetic.

Page 4: The Binary Number System

The Laws of Arithmetic

Succession

Addition

Multiplication

Page 5: The Binary Number System

Number Categories

Natural (Whole) The counting numbers

Negative Less than 0

Rational An integer, or the quotient of 2 integers

Page 6: The Binary Number System

Succession

Page 7: The Binary Number System

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.

Page 8: The Binary Number System

Positional Notation

103 102 101 100

10001 1001 101 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.

Page 9: The Binary Number System

Positional Notation

103 102 101 100

10001 1001 101 11

The base is 10.

Page 10: The Binary Number System

Positional Notation

103 102 101 100

10001 1001 101 11

The magnitude of the column is base exponent

Page 11: The Binary Number System

Positional Notation

104 103 102 101 100

10000 1000 100 10 1 2 7 9 1 6 20000+7000 +900 +10 +6

=27916 Consider a number like the one above. How many does it represent?

Page 12: The Binary Number System

Positional Notation

104 103 102 101 100

10000 1000 100 10 1 2 7 9 1 6 20000+7000 +900 +10 +6

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

Page 13: The Binary Number System

Positional Notation

104 103 102 101 100

10000 1000 100 10 1 2 7 9 1 6 20000+7000 +900 +10 +6

=27916 The columns are labelled with their exponents.

Page 14: The Binary Number System

Positional Notation

104 103 102 101 100

10000 1000 100 10 1 2 7 9 1 6 20000+7000 +900 +10 +6

=27916 The base of the system is 10.

Page 15: The Binary Number System

Positional Notation

104 103 102 101 100

10000 1000 100 10 1 2 7 9 1 6 20000+7000 +900 +10 +6

=27916 The magnitude of the column is base exponent

Page 16: The Binary Number System

Positional Notation

104 103 102 101 100

10000 1000 100 10 1 *2 *7 *9 *1 *6 20000+7000 +900 +10 +6

=27916 Multiply the magnitude of the column by the digit

in the column.

Page 17: The Binary Number System

Positional Notation

104 103 102 101 100

10000 1000 100 10 1 *2 *7 *9 *1 *6 20000+7000 +900 +10 +6 27 thousand, 9 hundred, sixteen

Sum the products.

Page 18: The Binary Number System

Binary Numbers

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 19: The Binary Number System

Positional Notation

In Binary, the columns have the expected exponents,

23 22 21 20

81 41 21 11

Page 20: The Binary Number System

Positional Notation

In Binary, the columns have the expected exponents,

but the base of the system is 2.

23 22 21 20

81 41 21 11

Page 21: The Binary Number System

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

Page 22: The Binary Number System

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 23: The Binary Number System

A Single Byte

27 26 25 24 23 22 21 20

128 64 32 16 8 4 2 1

1 1 1 1 1 1 1 1

128 +64 +32 +16 +8 +4 + 2 + 1

=255

Page 24: The Binary Number System

A Single Byte

27 26 25 24 23 22 21 20

128 64 32 16 8 4 2 1

1 1 1 1 1 1 1 1

128 +64 +32 +16 +8 +4 + 2 + 1

=255

Page 25: The Binary Number System

A Single Byte

27 26 25 24 23 22 21 20

128 64 32 16 8 4 2 1

1 1 1 1 1 1 1 1

128 +64 +32 +16 +8 +4 + 2 + 1

=255

Page 26: The Binary Number System

A Single Byte

27 26 25 24 23 22 21 20

128 64 32 16 8 4 2 1

1 1 1 1 1 1 1 1

128 +64 +32 +16 +8 +4 + 2 + 1

=255is the largest decimal value that can be expressed in 8 bits.

How many different patterns are there?

Page 27: The Binary Number System

A Single Byte

27 26 25 24 23 22 21 20

128 64 32 16 8 4 2 1

0 0 0 0 0 0 0 0

0 +0 +0 +0 +0 +0 + 0 + 0

=0There is also a representation for zero, making 256 (28)

combinations of 0 and 1, in 8 bits.

Page 28: The Binary Number System

Natural Numbers in Binary

Consider the pattern:

10010101

To calculate the Decimal equivalent:

1. multiply each digit by the value of the column

2. sum the products.

Page 29: The Binary Number System

Natural Numbers in Binary

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 30: The Binary Number System

Natural Numbers in Binary

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 31: The Binary Number System

Natural Numbers in Binary

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 32: The Binary Number System

Natural Numbers in Binary

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 33: The Binary Number System

Natural Numbers in Binary

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 34: The Binary Number System

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.

Page 35: The Binary Number System

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

0 1

Page 36: The Binary Number System

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

0 1

Page 37: The Binary Number System

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

0 1

Page 38: The Binary Number System

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

0 1 0 0 1

Page 39: The Binary Number System

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

0 1 0 0 1 0 0 1

Page 40: The Binary Number System

Natural Numbers in Binary

So the 8 bit binary representation of 73 is:

01001001

Page 41: The Binary Number System

Short Forms

Page 42: The Binary Number System

Longer Numbers

Since 255 is the largest number that can be represented in 8 bits, larger values simply require longer numbers.

For example, 27916 is represented by:

0011011010000110

Page 43: The Binary Number System

Longer Numbers

Since 255 is the largest number that can be represented in 8 bits, larger values simply require longer numbers.

For example, 27916 is represented by:

0011011010000110

Can you remember the Binary representation?

Page 44: The Binary Number System

Short Forms for Binary

Because large numbers require long strings of Binary digits, short forms have been developed to help deal with them.

An early system was called Octal.

It’s based on the 8 patterns in 3 bits.

Page 45: The Binary Number System

Short Forms for Binary - Octal111 7

110 6

101 5

100 4

011 3

010 2

001 1

000 0

0011011010000110

can be short-formed by dividing the number into 3 bit chunks (starting from the least significant bit) and replacing each with a single Octal digit.

Page 46: The Binary Number System

Short Forms for Binary - Octal111 7

110 6

101 5

100 4

011 3

010 2

001 1

000 0

000011011010000110

0 3 3 2 0 6added

Page 47: The Binary Number System

Short Forms for Binary - Hexadecimal0111 7 1111 F

0110 6 1110 E

0101 5 1101 D

0100 4 1100 C

0011 3 1011 B

0010 2 1010 A

0001 1 1001 9

0000 0 1000 8

It was later determined that using base 16 and 4 bit patterns would be more efficient.

But since there are only 10 numeric digits, 6 letters were borrowed to complete the set of hexadecimal digits.

Page 48: The Binary Number System

Short Forms for Binary - Hexadecimal0111 7 1111 F

0110 6 1110 E

0101 5 1101 D

0100 4 1100 C

0011 3 1011 B

0010 2 1010 A

0001 1 1001 9

0000 0 1000 8

0011011010000110

can be short-formed by dividing the number into 4-bit chunks (starting from the least significant bit) and replacing each with a single Hexadecimal digit.

Page 49: The Binary Number System

Short Forms for Binary - Hexadecimal0111 7 1111 F

0110 6 1110 E

0101 5 1101 D

0100 4 1100 C

0011 3 1011 B

0010 2 1010 A

0001 1 1001 9

0000 0 1000 8

0011011010000110

3 6 8 6

Page 50: The Binary Number System

Short Forms for Binary

Octal and Hexadecimal are number systems.

It is possible to perform arithmetic in both.

There are 64 (82) rules of octal addition, and 256 (162) rules of hexadecimal addition.

But why design a machine with so many rules when conversion to Binary is simple and there are only 4 rules of Binary addition?