elen 033 lecture #5 tokunbo ogunfunmi santa clara university

9
ELEN 033 Lecture #5 Tokunbo Ogunfunmi Tokunbo Ogunfunmi Santa Clara University Santa Clara University

Upload: clara-johnston

Post on 19-Jan-2016

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ELEN 033 Lecture #5 Tokunbo Ogunfunmi Santa Clara University

ELEN 033 Lecture #5ELEN 033 Lecture #5

Tokunbo OgunfunmiTokunbo Ogunfunmi

Santa Clara UniversitySanta Clara University

Page 2: ELEN 033 Lecture #5 Tokunbo Ogunfunmi Santa Clara University

Number SystemsNumber Systems

A computer’s A computer’s variables variables have to be have to be represented efficiently to reduce cost of represented efficiently to reduce cost of computing the instructionscomputing the instructions

Chosen method of representation affects the Chosen method of representation affects the difficulty of performing arithmetic difficulty of performing arithmetic operations.operations.

Page 3: ELEN 033 Lecture #5 Tokunbo Ogunfunmi Santa Clara University

Number System RepresentationsNumber System Representations

Unary systemUnary system Roman Numerals (see table)Roman Numerals (see table) Weighted Positional NotationWeighted Positional Notation

Binary (MSB ….. LSB)Binary (MSB ….. LSB) OctalOctal DecimalDecimal HexadecimalHexadecimal

Page 4: ELEN 033 Lecture #5 Tokunbo Ogunfunmi Santa Clara University

Number System RepresentationsNumber System Representations

Some of the desirable properties of number Some of the desirable properties of number system representations are system representations are

Uniqueness Uniqueness (no two numbers have the same (no two numbers have the same representations )representations )

Ability to rep. Ability to rep. any numberany number large/small including large/small including fractions, rationals, irrationals, etc. fractions, rationals, irrationals, etc. exactlyexactly

EfficiencyEfficiency of rep. to permit fast of rep. to permit fast implementations of mathematical operationsimplementations of mathematical operations

Page 5: ELEN 033 Lecture #5 Tokunbo Ogunfunmi Santa Clara University

Number System RepresentationsNumber System Representations

In a weighted positional rep., the radix/base In a weighted positional rep., the radix/base r r can be any integer (e.g. 2, 4, 8, 10, 16)can be any integer (e.g. 2, 4, 8, 10, 16)

The best choice for a computer is different The best choice for a computer is different from the best choice for humans. Why?….from the best choice for humans. Why?….

The higher the radix, the larger the numbers The higher the radix, the larger the numbers that can be rep. with same #digits.that can be rep. with same #digits.

Can easily convert numbers between one Can easily convert numbers between one radix and the other. radix and the other.

Page 6: ELEN 033 Lecture #5 Tokunbo Ogunfunmi Santa Clara University

What about negative numbers?What about negative numbers?

The weighted positional rep. can still be The weighted positional rep. can still be used to rep. zero, negative and fractional used to rep. zero, negative and fractional numbers.numbers.

Using + and -- to rep. positive and negative Using + and -- to rep. positive and negative numbers introduce additional symbols.numbers introduce additional symbols.

Instead, we use other means such as One’s Instead, we use other means such as One’s complement, Two’s complement, Sign-complement, Two’s complement, Sign-magnitude, etc.magnitude, etc.

Page 7: ELEN 033 Lecture #5 Tokunbo Ogunfunmi Santa Clara University

Transformations Between RadicesTransformations Between Radices

Arithmetic operations are performed with Arithmetic operations are performed with respect to a certain radix.respect to a certain radix.

Conversion involves three radices: original Conversion involves three radices: original rep. radix, final rep. radix and the radix in rep. radix, final rep. radix and the radix in which the arithmetic is performed.which the arithmetic is performed.

Conversion Conversion IntoInto Decimal, Conversion Decimal, Conversion FromFrom Decimal and Powers of Two Conversions. Decimal and Powers of Two Conversions. Examples are given ….Examples are given ….

Page 8: ELEN 033 Lecture #5 Tokunbo Ogunfunmi Santa Clara University

Representation of Non-Integer numbers

Representation of Non-Integer numbers

Extending weigthed positional rep. to Extending weigthed positional rep. to include non-integersinclude non-integers

Conversion of fractionsConversion of fractions Approximate ValuesApproximate Values Scientific NotationScientific Notation NormalizationNormalization

Page 9: ELEN 033 Lecture #5 Tokunbo Ogunfunmi Santa Clara University

Precision and AccuracyPrecision and Accuracy Precision is defined as …Precision is defined as …

Many computations have a fixed precision determined Many computations have a fixed precision determined by the maximum number of significant digits it is by the maximum number of significant digits it is capable of rep. correctly.capable of rep. correctly.

Accuracy is defined as …Accuracy is defined as … The accuracy of a computation is limited by the lesser The accuracy of a computation is limited by the lesser

of (1) the precision of the rep. and the computations of (1) the precision of the rep. and the computations and (2) the accuracy of the values used in the and (2) the accuracy of the values used in the computation.computation.

Accuracy can never be more (is usually less) than Accuracy can never be more (is usually less) than the precision of a computer.the precision of a computer.