Computer Fluency Binary Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10)...

19
Computer Fluency Binary Systems

Transcript of Computer Fluency Binary Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10)...

Page 1: Computer Fluency Binary Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10) Sign-Magnitude (-324) Sign-Magnitude (-324) Decimal Fractions.

Computer Fluency

Binary Systems

Page 2: Computer Fluency Binary Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10) Sign-Magnitude (-324) Sign-Magnitude (-324) Decimal Fractions.

Humans

Decimal Numbers (base 10)

Sign-Magnitude (-324)

Decimal Fractions (23.27)

Letters for text

Page 3: Computer Fluency Binary Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10) Sign-Magnitude (-324) Sign-Magnitude (-324) Decimal Fractions.

Computers

Binary Numbers (base 2)

Two’s complement and sign-magnitude

Binary fractions and floating point

ASCII codes for characters (A65)

Page 4: Computer Fluency Binary Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10) Sign-Magnitude (-324) Sign-Magnitude (-324) Decimal Fractions.

Why binary? Computers are ‘electronic’ and use the

presence or absence of electricity to provide values

Using decimal would require 10 distinct and reliable voltage levels for each digit.

This is not feasible with reasonable reliability and financial constraints.

Everything in computer is stored using binary: numbers, text, programs, pictures, sounds, videos, ...

Page 5: Computer Fluency Binary Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10) Sign-Magnitude (-324) Sign-Magnitude (-324) Decimal Fractions.

Transistor A transistor is an electronic

switch (on/off) and is thebasic unit of modern computer processors

Two steady states based on voltage levels

As of 2015, the highest transistor count in a commercially available CPU (in one chip) is over 4.3 billion transistors, in Intel's 15-core Xeon Ivy Bridge-EX.

Change states in billionth of sec Intel Makes the 3D Transistor

Page 6: Computer Fluency Binary Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10) Sign-Magnitude (-324) Sign-Magnitude (-324) Decimal Fractions.

Binary Representations

Binary values are represented abstractly by:• digits 0 and 1• words (symbols) False (F) and True (T)• words (symbols) Low (L) and High (H) • and words Off and On.

• OR …..

Page 7: Computer Fluency Binary Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10) Sign-Magnitude (-324) Sign-Magnitude (-324) Decimal Fractions.

Morse CodeBinary communications are not a new concept

Page 8: Computer Fluency Binary Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10) Sign-Magnitude (-324) Sign-Magnitude (-324) Decimal Fractions.

Decimal: Non-negatives Base 10

Uses decimal digits: 0,1,2,3,4,5,6,7,8,9

Positional System - position gives power of

the base

Example:3845 = 3x103 + 8x102 + 4x101 +

5x100

Positions: …543210

Page 9: Computer Fluency Binary Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10) Sign-Magnitude (-324) Sign-Magnitude (-324) Decimal Fractions.

Binary: Non-negatives

Base 2

Uses binary digits (bits): 0,1

Positional system

Example:1101 = 1x23 + 1x22 + 0x21 +

1x20

Page 10: Computer Fluency Binary Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10) Sign-Magnitude (-324) Sign-Magnitude (-324) Decimal Fractions.

Powers of 2: 2n

n 2n

0

1

2

3

4

5

6

7

8

9

10

1

2

4

8

16

32

64

128

256

512

1024

It will be convenient to remember these powers

Page 11: Computer Fluency Binary Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10) Sign-Magnitude (-324) Sign-Magnitude (-324) Decimal Fractions.

Base Two

The important details about base 2 are that the symbols that you use are 0 and 1. The place values in base 2 are (going from smallest to largest):

2-5

()2-4

()2-3

()2-2

()2-1

()20

(1)21

(2)22

(4)23

(8)24

(16)25

(32)

Change the base 2 number 1100112 to a base 10 (decimal) number.1100112

11 = 1 12 = 2 04 = 0 08 = 0116 = 16132 = 32 51

Change the base 10 (decimal) number 47 to a base 2 (binary) number.

47 2 = 23 remainder 1

23 2 = 11 remainder 1

11 2 = 5 remainder 1

5 2 = 2 remainder 1

2 2 = 1 remainder 0

1 2 = 0 remainder 1

47 = 1011112

Binary Point

Page 12: Computer Fluency Binary Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10) Sign-Magnitude (-324) Sign-Magnitude (-324) Decimal Fractions.

Conversions

External Internal(Human) (Computer) 25 11001 A 01000001

Humans want to see and enter numbers in decimal.

Computers must store and compute with bits.

Page 13: Computer Fluency Binary Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10) Sign-Magnitude (-324) Sign-Magnitude (-324) Decimal Fractions.

Binary to Decimal Conversion

Algorithm:• Expand binary number using positional

scheme.• Perform computation using decimal

arithmetic. Example:

110012 1x24 + 1x23 + 0x22 + 0x21 + 1x20

= 24 + 23 + 20

= 16 + 8 + 1 = 2510

Page 14: Computer Fluency Binary Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10) Sign-Magnitude (-324) Sign-Magnitude (-324) Decimal Fractions.

Binary Addition

One bit numbers:+ 0 1

0 | 0 1 1 | 1 10

Example 1111 1

110101 (53) + 101101 (45) 1100010 (98)

Page 15: Computer Fluency Binary Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10) Sign-Magnitude (-324) Sign-Magnitude (-324) Decimal Fractions.

Special Powers of 2

210 (=1024) is Kilo, denoted "K"

220 (=1,048,576) is Mega, denoted "M"

230 (1,073, 741,824) is Giga, denoted "G"

240 (1,099,511,627,776 ) is Tera, denoted “T"

Reminder: 8 bits (b) are also called a byte (B)

Exercise: what is the most memory (RAM) a 32-bit processor can access?

1111 1111 1111 1111 1111 1111 1111 1111 equals what in decimal?

Page 16: Computer Fluency Binary Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10) Sign-Magnitude (-324) Sign-Magnitude (-324) Decimal Fractions.

Octal Numbers

Base 8 Digits 0,1,2,3,4,5,6,7

Number does not have so many digits as binary

Easy to convert to and from binary

Often used by people who need to see the internal representation of data, programs, etc.

Page 17: Computer Fluency Binary Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10) Sign-Magnitude (-324) Sign-Magnitude (-324) Decimal Fractions.

Octal Conversions

Octal to Binary• Simply convert each octal digit to a

three bit binary number.• Example:

5368 = 101 011 1102

Binary to Octal• Starting at right, group into 3 bit

sections• Convert each group to an octal digit• Example

110111111010102 = 011 011 111 101 010 = 337528

Page 18: Computer Fluency Binary Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10) Sign-Magnitude (-324) Sign-Magnitude (-324) Decimal Fractions.

Hexadecimal Base 16 Digits 0,…,9,A,B,C,D,E,F

Hexadecimal Binary• Just like Octal, only use 4 bits per digit.

Example:98C316 = 1001 1000 1100 00112

Example110100111010112 = 0011 0100 1110 1011

= 34EB

Page 19: Computer Fluency Binary Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10) Sign-Magnitude (-324) Sign-Magnitude (-324) Decimal Fractions.

ASCII Character Codes

American Standard Code for Information Interchange (ASCII)

This code is a standard used to represent information sent as character-based data. The Extended ASCII set uses 8-bits to represent:• 224 Graphic printing characters.• 32 Non-printing characters

Some non-printing characters are used for text format (e.g. BS = Backspace, CR = carriage return)

ASCII Table - http://www.ascii-code.com/