21
Chapter 1.5 The Binary System CSCI 3

Chapter 1.5 The Binary System CSCI 3. Basic Concepts Behind the Binary System In the decimal system, things are organized into columns – H | T | O – 1

  • View
    223

  • Download
    2

Embed Size (px)

Citation preview

Chapter 1.5 The Binary System

CSCI 3

Basic Concepts Behind the Binary System

In the decimal system, things are organized into columns

– H | T | O – 1 | 9 | 3 – such that "H" is the hundreds column, "T" is the tens

column, and "O" is the ones column. So the number "193" is 1-hundreds plus 9-tens plus 3-ones

– ones column meant 10^0, the tens column meant 10^1, the hundreds column 10^2 and so on

– the number 193 is really {(1*10^2)+(9*10^1)+(3*10^0)}.

The base ten system

A. Base ten system (375)

3 7 5 Representation

Hundred Ten One

(10^2) (10^1) (10^0)

Position’s quantity

* Figure 1.15, Page 41

The base binary system

A. Base two system (1011)

1 0 1 1 Representation

Eight Four Two One

(2^3) (2^2) (2^1) (2^0)

Position’s quantity

* Figure 1.15, Page 41

Basic Concepts Behind the Binary System

The binary system works under the exact same principles as the decimal system, only it operates in base 2 rather than base 10.

In other words, instead of columns being 10^2|10^1|10^0 they are 2^2|2^1|2^0

Basic Concepts Behind the Binary System

Instead of using the digits 0-9, we only use 0 and 1.

Examples: What would the binary number 1011 be in decimal notation? – It would be 2^3+0+2^1+1– Which will be 8+2+1=11

Basic Concepts Behind the Binary System

Try converting these numbers from binary to decimal: – 10 – 111 – 10101 – 11110

Remember:– |2^4| 2^3| 2^2| 2^1| 2^0 |

Basic Concepts Behind the Binary System

Try converting these numbers from binary to decimal:

10=(1*2^1) + (0*2^0) = 2+0 = 2 111 = (1*2^2) + (1*2^1) + (1*2^0) = 4+2+1=7 10101= (1*2^4) + (0*2^3) + (1*2^2) + (0*2^1)

+ (1*2^0)=16+0+4+0+1=21 11110= (1*2^4) + (1*2^3) + (1*2^2) + (1*2^1)

+ (0*2^0)=16+8+4+2+0=30

Basic Concepts Behind the Binary System

Binary Addition– Consider the addition of decimal numbers:– 23 – +48– ___

We begin by adding 3+8=11. Since 11 is greater than 10, a one is put into the 10's column (carried), and a 1 is recorded in the one's column of the sum. Next, add {(2+4) +1} (the one is from the carry)=7, which is put in the 10's column of the sum. Thus, the answer is 71.

Basic Concepts Behind the Binary System

Binary addition works on the same principle, but the numerals are different. Begin with one-bit binary addition:– 0 0 1 – +0 +1 +0 – =0 1 1

Basic Concepts Behind the Binary System

1+1 carries us into the next column. In decimal form, 1+1=2. In binary, any digit higher than 1 puts us a column to the left (as would 10 in decimal notation). The decimal number "2" is written in binary notation as "10" (1*2^1)+(0*2^0). Record the 0 in the ones column, and carry the 1 to the twos column to get an answer of "10." In our vertical notation,

– 1 – + 1– =10

Basic Concepts Behind the Binary System

Example:– 1010 – +1111

– Step one: Column 2^0: 0+1=1.Record the 1. Temporary Result: 1; Carry: 0

– Step two: Column 2^1: 1+1=10. Record the 0, carry the 1.Temporary Result: 01; Carry: 1

– Step three: Column 2^2: 1+0=1 Add 1 from carry: 1+1=10. Record the 0, carry the 1.Temporary Result: 001; Carry: 1

– Step four: Column 2^3: 1+1=10. Add 1 from carry: 10+1=11.Record the 11. Final result: 11001

Basic Concepts Behind the Binary System

Always remember – 0+0=0 – 1+0=1 – 1+1=10

Basic Concepts Behind the Binary System

Try a few examples of binary addition:– 111+110– 101+111– 111+111

Basic Concepts Behind the Binary System

Answer:– 111+110=1101– 101+111=1100– 111+111=1110

Basic Concepts Behind the Binary System

How to find the binary representation of a positive integer?

Basic Concepts Behind the Binary System

Basic Concepts Behind the Binary System

Example:– 52 in decimal 110100 in binary– What about 10 (1010)? Or other numbers?

Basic Concepts Behind the Binary System

To extend binary notation to accommodate fractional number values, we use a “radix point.”

1011.0111

radix point

Basic Concepts Behind the Binary System

Homework #4