Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Understanding Number Systems: Analog & Digital Signals, Binary & Decimal Conversion, Slides of Digital Logic Design and Programming

An overview of number systems, focusing on the differences between analog and digital signals, binary representation systems, and the conversion of decimal numbers to binary. Students will learn about the concept of place values, the conversion of decimal numbers to binary using powers of 2, and the use of shortcuts for binary, octal, and hexadecimal conversions.

Typology: Slides

2021/2022

Uploaded on 09/12/2022

sergeybrin
sergeybrin 🇺🇸

4.6

(8)

236 documents

1 / 12

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
3.1
Unit 3
Binary Representation
3.2
ANALOG VS. DIGITAL
3.3
Analog vs. Digital
The analog world is based on
continuous events.
Observations can take on
(____) any value.
The digital world is based on
discrete events. Observations
can only take on a _______
number of discrete values
3.4
Analog vs. Digital
Q. Which is better?
A. Depends on what you are trying to do.
Some tasks are better handled with analog
data, others with digital data.
Analog means continuous/real valued signals with
an infinite number of possible values
Digital signals are discrete [i.e. 1 of n values]
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Understanding Number Systems: Analog & Digital Signals, Binary & Decimal Conversion and more Slides Digital Logic Design and Programming in PDF only on Docsity!

Unit 3

Binary Representation

ANALOG VS. DIGITAL

Analog vs. Digital

The analog world is based oncontinuous events.Observations can take on(____) any value.

The digital world is based ondiscrete events. Observationscan only take on a _______number of discrete values

Analog vs. Digital

Q. Which is better?

A. Depends on what you are trying to do.

Some tasks are better handled with analogdata, others with digital data.

Analog means continuous/real valued signals withan infinite number of possible values

Digital signals are discrete [i.e. 1 of n values]

Analog vs. Digital

How much money is in my checking account?^ –

Analog: Oh, some, but not too much.

Digital: $243.

Analog vs. Digital

How much do you love me?

Analog: I love you with all my heart!!!!

Digital: 3.2 x 10

3

MegaHearts

The Real (Analog) World

The real world is inherently analog.

To interface with it, our digital systems needto:^ –

Convert analog signals to digital values (numbers)at the input.

Convert digital values to analog signals at theoutput.

Analog signals can come in many forms^ –

Voltage, current, light, color, magnetic fields,pressure, temperature, acceleration, orientation

Digital is About Numbers

In a digital world, numbers are used to represent allthe possible discrete events (i.e. 1-of-n possibilities)

Numerical values (5.7, 1923.8, …)

Computer instructions (ADD, SUB, BLE, …)

Characters ('a', 'b', 'c', …)

Conditions (on, off, ready, paper jam, …)

Numbers allow for easy manipulation

Add, multiply, compare, store, …

Results are repeatable

Each time we add the same two number we getthe same result

4 Skills

We will teach you 4 skills that you shouldknow and be able to apply with confidence^ –

Convert a number in any base (base r) to decimal(base 10)

Convert a decimal number (base 10) to binary

Use the shortcut for conversion between binary(base 2) and hexadecimal (base 16)

Understand the finite number of combinationsthat can be made with n bits (binary digits) and itsimplication for codes including ASCII and Unicode

Number Systems

Number systems consist of

1. A base (radix) r2. ___ coefficients ___________

Human System:

Decimal (Base 10):

Computer System:

Binary (Base 2): 0,

Human systems for working with computer systems(shorthand for human to read/write binary)

Octal (Base 8): 0,1,2,3,4,5,6,

Hexadecimal (Base 16): 0-9,A,B,C,D,E,F

(A thru F = 10 thru 15)

Skill 1: Converting to Decimal

-^

Number systems use implied place values (weights) that arepowers of the base( ____

____ ___. ____ )

10

( ___ ___ ___ ___. ____ ____ )

2

10

2 =100 10

1 =10 10

0 =1 10

=0.

(^32) =8 2

2 =

(^12) =2 2

0 =1 2

=0.5 2

=0.

-^

Converting from

another base

to

decimal

requires summing the

product of each digit with its implied place value

(^

.^

)^2

(_________)

10

__

__

__

__



Conversion Examples 1

__

__

__

(1A5)

___

+ ___*

___

___

Skill 2: Converting from Decimal

-^

Number systems use implied place values (weights) that arepowers of the base( ____

____ ___. ____ )

10

( ___ ___ ___ ___. ____ ____ )

2

10

2 =100 10

1 =10 10

0 =1 10

=0.

(^32) =8 2

2 =

(^12) =2 2

0 =1 2

=0.5 2

=0.

-^

Converting from

decimal

to

another base

requires finding the

digits that, when multiplied times each place value, will sum to thedesired value (i.e. making change).

10

( ___ ___ ___ ___ ___. ___ ___ )

2

16

8

4

2

1

Conversion Examples 2

)^2

)^16

Shortcuts for Converting Binary (r=2), Hexadecimal (r=16) and Octal (r=8) SHORTHAND FOR BINARY

Binary, Octal, and Hexadecimal

Octal (base 8 = 2

3

1 Octal digit (? )

8

can

represent: _______

3 bits of binary (?? ?)

2

can represent:000-111 = _______

Conclusion…1 Octal digit = ________

Hex (base 16=

4

1 Hex digit (? )

16

can

represent: _________

4 bits of binary(??? ?)

2

can represent:

Conclusion…1 Hex digit = _______

Binary Representation Systems

-^

Integer Systems^ –

Unsigned

-^

Unsigned (Normal) binary

Signed

-^

Signed Magnitude

-^

2’s complement

-^

1’s complement*

-^

Excess-N*

-^

Floating Point*^ –

For very large and small(fractional) numbers

-^

Codes

Text

-^

ASCII / Unicode

Decimal Codes

•^

BCD (Binary Coded Decimal)/ (8421 Code)

  • = Not covered in this class

Skill 4: Unique Combinations

Given

n

digits of base

r

, how many unique numbers can be

formed?

__

What is the range? [

___________

]

Use the examples below to generalize the relationship

Main Point: Given n digits of base r,

___

unique numbers

can be made with the range [_________]

2-digit, decimal numbers (r=10, n=2)3-digit, decimal numbers (r=10, n=3)4-bit, binary numbers (r=2, n=4)6-bit, binary numbers

(r=2, n=6)

0-

0-

100 combinations:

00-

0-

0-

0-

0-

1000 combinations:

000- 16 combinations:

0000- 64 combinations: 000000-

Approximating Large Powers of 2

-^

Often need to find decimalapproximation of a large powers of 2like 2

16

32

, etc.

-^

Use following approximations:^ –

10

20

30

40

-^

For other powers of 2, decomposeinto product of 2

10

or 2

20

or 2

30

and a

power of 2 that is less than 2

10

16-bit half word: ___ numbers

32-bit word: ____ numbers

64-bit dword: 16 million trillion numbers

(^162)

= (^242)

= (^282)

= (^322)

=

Binary Codes

Using binary we can represent any kind ofinformation by coming up with a code

Using

n

bits we can represent 2

n

distinct items

Colors of the rainbow:•Red = 000•Orange = 001•Yellow = 010•Green = 100•Blue = 101•Purple = 111

Letters:•‘A’ = 00000•‘B’ = 00001•‘C’ = 00010

...

•‘Z’ = 11001

ASCII Code

Used for representing text characters

Originally 7-bits but usually stored as ___________________ in modern computer systems

Example:

"Hello\n"

Each character is converted to ASCII equivalent

•^

‘H’ = 0x48, ‘e’ = 0x65, …

-^

\n = newline character is represented by either one or two ASCIIcharacter

LF (0x0A) = line feed (moves cursor down a line) - CR (0x0D) = carriage return character (moves cursor to start of currentline) - Newline for Unix / Mac = LF only - Newline for Windows = CR + LF

ASCII Table

LSD/MSD

0

1

2

3

4

5

6

7

0

NULL

DLW

SPACE

0

@

P^

`^

p

1

SOH

DC

!^

1

A^

Q^

a^

q

2

STX

DC

“^

2

B^

R^

b^

r

3

ETX

DC

#^

3

C^

S^

c^

s

4

EOT

DC

$^

4

D^

T^

d^

t

5

ENQ

NAK

%

5

E^

U^

e^

u

6

ACK

SYN

&

6

F^

V^

f^

v

7

BEL

ETB

‘^

7

G^

W

g^

w

8

BS

CAN

(^

8

H^

X^

h^

x

9

TAB

EM

)^

9

I^

Y^

i^

y

A^

LF

SUB

*^

:^

J^

Z^

j^

z

B^

VT

ESC

+^

;^

K^

[^

k^

{

C^

FF

FS

,^

<^

L^

^

l^

|

D^

CR

GS

-^

=^

M

]^

m

}

E^

SO

RS

.^

^

N^

^^

n^

~

F^

SI

US

/^

?^

O^

_^

o^

DEL

'M' = 0x4D = 0100 1101

UniCode

•^

ASCII can represent only the Englishalphabet, decimal digits, andpunctuation^ –

7-bit code => 2

7 = 128 characters

It would be nice to have one codethat represented morealphabets/characters for commonlanguages used around the world

•^

Unicode^ –

Up to 32-bit Code => up to 4 billioncombinations

137,000 character defined for manylanguages

Used by Java as standard charactercode

Unicode hex value

(i.e. FB52 => 1111101101010010)

Review: Chars and Ints

-^

The C/C++ language supports types

char

and

int

. Let's see

what you know about these:

True/False

Question

____

In C/C++: '1' and 1 are the same.- '1' is replaced with its equiv. _______________________- Thus, storing '1' or ______________ to a char variable are allequivalent (the hardware does not ___________ how the bits willbe interpretated…that is up to the code)

____

chars and ints have different ranges of the values they canrepresent.-^

Range of char: _________________

-^

______________________________

____

chars are only for ASCII characters(e.g.

char c =

and not

char c =

Using positional weights/place values BASE R TO BASE 10

Skill 1: Converting Base r to Decimal

•^

10

10

10

2 =

10

1 =

10

0 =

10

=0.

•^

2

10

2 3 =

2 2 =

2 1 =

(^02)

-1 2

=0.

•^

3B.

16

B

10

16

1 =

16

0 =

16

=0.

Main Point

: To convert any base to decimal (base 10), apply the

implicit place values (weights) which are just the powers of the

base and sum each digit times its place value.

General Conversion From Base r to Decimal •

A number in base r has place values/weightsthat are the powers of the base

Denote the coefficients as: a

i

Left-most digit =Most Significant

Digit (MSD)

Right-most digit =Least Significant

Digit (LSD)

N

r^

(ai

*ri

i) => D

(a

a 3

a 2

a 1

.a 0

-

a

-

)r

a

*r 3

3

+ a

*r 2

2

+ a

*r 1

1

+ a

*r 0

0

+ a

-

*r

-

a

-

*r

-

Number in base r

Decimal Equivalent

(^1

)r

3

2

1

0

-

-

Generalized approach: Example:

Examples

(1A5)

(AD2)

Binary Examples

. 1 2 4 8

16 32

128

1

Powers of 2

512

256

128

64

32

16

8

4

2

1

1024

It helps to memorize the first 11 powers of 2^2

0

4

5

6

7

8

9

10

"Making change" BASE 10 TO BASE 2 OR BASE 16

Skill: Decimal to Base r

•^

To convert a decimal number,

x,

to binary:

Only coefficients of 1 or 0. So simply find place valuesthat add up to the desired values, starting with largerplace values and proceeding to smaller values and placea 1 in those place values and 0 in all others

Similar to how one would

make change

16

8

4

2

1

25

10

=

1

1

1

32

For 25

10

the place value 32 is too large to include so we include

16. Including 16 means we have to make 9 left over. Include 8

and 1.

0

0

0