m1 – digital systems and binary numbers · module outline representation of information –...

28
M1 – Digital Systems and Binary Numbers

Upload: others

Post on 14-Jul-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers

M1 – Digital Systems and Binary Numbers

Page 2: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers

Module Outline● Representation of information

– characters, signed and unsigned integers● 2’s complement representation of signed

numbers● IEEE 754 floating point representation

Page 3: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers

Real Data● 3.14159265 ... (pi), 2.71828 ... (e)● 0.00001 = 1.0 x 10-5

● 3,155,760,000 = 3.15576 x 10-9

Page 4: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers

Real Data● 3.14159265 ... (pi), 2.71828 ... (e)● 0.00001 = 1.0 x 10-5

● 3,155,760,000 = 3.15576 x 10-9

● Scientific form of a real number– Single digit before the decimal point– 1.0 x 10-5, 0.1 x 10-4, 0.01 x 10-3, ...

Page 5: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers

Real Data● 3.14159265 ... (pi), 2.71828 ... (e)● 0.00001 = 1.0 x 10-5

● 3,155,760,000 = 3.15576 x 10-9

● Scientific form of a real number– Single digit before the decimal point– 1.0 x 10-5, 0.1 x 10-4, 0.01 x 10-3, ...

● Normalized representation– No leading zeros– 1.0 x 10-5

– Not 0.1 x 10-4, 0.01 x 10-3, ...

Page 6: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers

Real Data – Binary Notation● 7.510 = (______)2

Page 7: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers

Real Data – Binary Notation● 7.510 = (______)2

23 22 21 20 2-1 2-2 2-3. ...

binary point

...

Page 8: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers

Real Data – Binary Notation● 7.510 = (______)2

● 7.2510 = (______)2

● 7.12510 = (______)2

● 7.7510 = (______)2

● 7.37510 = (______)2

● 7.62510 = (______)2

● 7.87510 = (______)2

Page 9: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers

Real Data – Binary Notation● 7.62510 = 111.1012

Page 10: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers

Real Data – Binary Notation● 7.62510 = 111.1012

● 111.101 x 20, 1111.01 x 2-1, 11.1101 x 21, ...

Page 11: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers

Real Data – Binary Notation● 7.62510 = 111.1012

● 111.101 x 20, 1111.01 x 2-1, 11.1101 x 21, ... ● Scientific form

– 1.11101 x 22, 0.111101 x 23, 0.0111101 x 24, ...

Page 12: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers

Real Data – Binary Notation● 7.62510 = 111.1012

● 111.101 x 20, 1111.01 x 2-1, 11.1101 x 21, ... ● Scientific form

– 1.11101 x 22, 0.111101 x 23, 0.0111101 x 24, ...● Normalized representation

– 1.11101 x 22

Page 13: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers

Real Data – Binary Notation● 7.62510 = 111.1012

● 111.101 x 20, 1111.01 x 2-1, 11.1101 x 21, ... ● Scientific form

– 1.11101 x 22, 0.111101 x 23, 0.0111101 x 24, ...● Normalized representation

– 1.11101 x 22

● Computers use Normalized representation to store floats.– 1.f x 2e

– f: fraction, e: exponent.

Page 14: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers

Floating Point Representation

(−1)s×1. f ×2e−127

31 30 .... .... ... .... 23 22 21 ..... ...... ...... ..... .... .... ... .... 1 0

s exponent fraction

Page 15: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers

Floating Point Representation

(−1)s×1. f ×2e−127

31 30 .... .... ... .... 23 22 21 ..... ...... ...... ..... .... .... ... .... 1 0

s exponent fraction

● IEEE 754 single precision format● Exponent is biased by 127

Page 16: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers

IEEE 754 FP Representation● Convert 0.5 into binary. Represent in IEEE 754

single precision floating point representation.

Page 17: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers

IEEE 754 FP Representation● Convert 0.5 into binary. Represent in IEEE 754

single precision floating point representation.● Binary = 0.1 = 1.0 x 2-1. ● s=?, f = ?, e = ?

Page 18: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers

IEEE 754 FP Representation● Convert 0.5 into binary. Represent in IEEE 754

single precision floating point representation.● Binary = 0.1 = 1.0 x 2-1. ● s=?, f = ?, e = ?● s=0, f=0, e = (-1) + 127 = 126

Page 19: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers

IEEE 754 FP Representation● Convert 0.5 into binary. Represent in IEEE 754

single precision floating point representation.● Binary = 0.1 = 1.0 x 2-1. ● s=?, f = ?, e = ?● s=0, f=0, e = (-1) + 127 = 126

0 0 1 1 1 1 1 1 0 0 0 ... 0 0

0x3F000000

Page 20: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers

IEEE 754 FP Representation

● Convert 0.75 into IEEE 754 SP FP.

Page 21: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers

IEEE 754 FP Representation

● Convert the SP FP sequence 0xBDCCCCCC into decimal.

Page 22: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers

IEEE 754 FP Representation

● Four special values

Exponent Fraction Value

0 0 Zero (± 0)

255 0 Infinity (± ∞)

0 ≠ 0 Denormal numbers(± 0.M x 2-126)

255 ≠ 0 NaN (0/0 or √-1)

Page 23: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers

IEEE 754 Double Precision

(−1)s×1. f ×2e−1023

63 62 .... .... ... .... 52 51 50 ..... ...... ...... ..... .... .... ... .... 1 0

s exponent fraction

Page 24: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers

Module Outline● Representation of information

– characters, signed and unsigned integers● 2s complement representation of signed

numbers● IEEE 754 floating point representation

Page 25: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers
Page 26: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers

Real Data Representation – Recap● Convert into IEEE 754 SP FP:

– 13.1, 12.2, 11.3, 10.4, 9.5, 8.6, 7.7, 6.8, 5.9

Page 27: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers

Biased Representation● The most negative value is represented by 0.

0000 00000000 0001

0000 0010

0111 11100111 11111000 00001000 00011000 0010

1111 1110

1111 1111

012

126127

-128-127-126

-2-1

.....

.....

0000 00000000 0001

0000 0010

0111 11100111 1111

1000 00001000 00011000 0010

1111 1110

1111 1111

012

126127

-128-127-126

-2-1

.....

.....

Two's Complement Biased Notation (Biased by 128)

(Excess 128)

Page 28: M1 – Digital Systems and Binary Numbers · Module Outline Representation of information – characters, signed and unsigned integers 2’s complement representation of signed numbers

Biased Representation● The most negative value is represented by 0.

0000 00000000 0001

0000 0010

0111 11100111 11111000 00001000 00011000 0010

1111 1110

1111 1111

012

126127

-128-127-126

-2-1

.....

.....

0000 00000000 0001

0000 0010

0111 11100111 1111

1000 00001000 00011000 0010

1111 1110

1111 1111

012

126127

-128-127-126

-2-1

.....

.....

Two's Complement Biased Notation (Biased by 128)

(Excess 128)