Docsity

Arithmetic Data Types in CS: Integer, Fixed Point, Floating Point, and Accumulator Types, Study notes of Computer Architecture and Organization

Toggle sidebar
bg1
1
CS231 Spring 2006
Computer Arithmetic:
Advanced Topics in Number
Representation
Arithmetic Data Types
zIntegers
zTwo’s Complement, One’s Complement, Signed Magnitude
z(We have already seen these.)
zFixed Point Fractions
zThe data types used by signal and media processors
zThe subject of this slide set.
zFloating Point
zIEEE 754 Single, Double, Extended
zSee additional slides on this data type
There are three important categories of
arithmetic data types used in various kinds of
computers:
Data Types By Application
zInteger
zBusiness, Systems Programming, User Interfaces, General
Purpose Computation
zFloating Point
zScientific Computation
zFixed Point Fractions
zCommunications, Media Processing
zThis is a simplification; in reality all these data types
can be used in many different applications
Properties of the Types
zInteger
zRepresent positive and negative whole numbers
zAll the integers between a MIN and MAX can be
represented
zFixed Point Fractions
zSigned: represent values in the range -1 to (almost) 1
zUnsigned: values in the range 0 to (almost) 1
zFloating Point
zRepresent numbers in a huge range
zNumbers very close to 0, and numbers very far from 0
z-10100 10-100 10100 10-100
zBut unevenly distributed (many holes in the range)
Types for Signal and Media
Processing
zSignal and media processing uses most every
arithmetic type you can think of:
zFixed point
zIntegers (signed and unsigned)
zFractions (signed and unsigned)
zMixed integers / fractions (e.g., accumulator types)
zFloating point
zOf various precisions. Even 16-bit floating point!
zComplex numbers <real, imaginary>
zFixed point
zFloating point
Signal Data
•Signal data often
originates from A/D
conversion
•An analog signal is
sampled at fixed time
intervals (see clock
below)
•A stream of numbers
emerges from the A/D
converter
•These numbers lie in a
fixed range, and
represent the instaneous
amplitude of the signal
pf3

Partial preview of the text

Download Arithmetic Data Types in CS: Integer, Fixed Point, Floating Point, and Accumulator Types and more Study notes Computer Architecture and Organization in PDF only on Docsity!

CS231 Spring 2006

Computer Arithmetic:

Advanced Topics in Number

Representation

Arithmetic Data Types

z Integers

z Two’s Complement, One’s Complement, Signed Magnitude

z (We have already seen these.)

z Fixed Point Fractions

z The data types used by signal and media processors

z The subject of this slide set.

z Floating Point

z IEEE 754 Single, Double, Extended

z See additional slides on this data type

There are three important categories of arithmetic data types used in various kinds of computers:

Data Types By Application

z Integer

z Business, Systems Programming, User Interfaces, General

Purpose Computation

z Floating Point

z Scientific Computation

z Fixed Point Fractions

z Communications, Media Processing

z This is a simplification; in reality all these data types

can be used in many different applications

Properties of the Types

z Integer

z Represent positive and negative whole numbers

z All the integers between a MIN and MAX can be

represented

z Fixed Point Fractions

z Signed: represent values in the range -1 to (almost) 1

z Unsigned: values in the range 0 to (almost) 1

z Floating Point

z Represent numbers in a huge range

z Numbers very close to 0, and numbers very far from 0

z -10 100 10 -100^10 100 10 -

z But unevenly distributed (many holes in the range)

Types for Signal and Media

Processing

z Signal and media processing uses most every

arithmetic type you can think of:

z Fixed point

z Integers (signed and unsigned) z Fractions (signed and unsigned) z Mixed integers / fractions (e.g., accumulator types)

z Floating point

z Of various precisions. Even 16-bit floating point!

z Complex numbers <real, imaginary>

z Fixed point z Floating point

Signal Data

•Signal data often originates from A/D conversion •An analog signal is sampled at fixed time intervals (see clock below) •A stream of numbers emerges from the A/D converter •These numbers lie in a fixed range, and represent the instaneous amplitude of the signal

Fixed Point Types

MAGNITUDE .

MAGNITUDE .

SIGN

UNSIGNED INTEGER:

INTEGER:SIGNED

MAGNITUDE .

MAGNITUDE .

SIGN

UNSIGNED FRACTION:

SIGNED FRACTION:

0 .. 2N^ -

-2N-1^ .. 2N-1-

0 .. 1 - 2-N

-1 .. 1 - 2-N+

Binary point

Unsigned Fixed Point

Fractions

z “0.16” = 16 bits of fractional magnitude, binary point

fully at left

z “0.32” = 32 bits of fractional magnitude

z Addition and multiplication work exactly as for twos-

complement integers

z .1000 X .1000 =.

z But: discard the lower bits if the final value has same preceision as the inputs!

z .1000 + .1000 = 1.0000 (overflow)

z If saturating arithmetic is used, 1.0000 is rounded to the nearest reprentable value, .1111 in this case.

Signed Fixed Point Fractions

z “1.15” = 1 sign bit, 15 magnitude bits

z “1.31” = 1 sign bit, 31 magnitude bits

z 0100 = ½

z 1100 = -½

z Most positive value = 0111 … 11

z Most negative value = 1000 … 00

z Multiplication produces two sign bits:

z 0.100 X 0.100 = 00.

z One is normally shifted away to yield 1.N format (shift

result left by one bit)

z This is usually done by the multiply instruction (or multiply-

accumulate instruction)

Multiplication

z Multiplication of M bits by N bits produces

M + N bits.

z E.g., 32 × 16 → 48

z Subsequent truncation, rounding, saturation, etc., is

a separate operation (conceptually)

z If you keep these discrete steps straight in your

head you won’t be confused about multiplication.

z Note that 1.15 × 0.16 yields 1.31. No redundant

sign bit in this case.

z When we multiply 32 × 32 in a C program, which 32

bits are discarded from the 64-bit product?

Multiplication Continued

z 32 × 32 multiply yields 64 bits

z If we are performing integer arithmetic and want a

32-bit result, we discard the upper 64 bits of the

result

z Works great unless there is an overflow!

z Rather disastrous if there is an undetected overflow

however, because we are discarding the most significant

bits of the result

z In signal processing and when working with

fractional types, we discard LSBs of a product

z This is much safer of course

Accumulator Types

S GUARD MAGNITUDE

S MAGNITUDE

S GUARD MAGNITUDE

S MAGNITUDE

ACCUMULATOR:

REGISTER:

•Guard bits are initialized by sign-extending the 1. form. I.e., guard bits = sign bit initially •1.31 values are sign- extended to 9.31 in order to add them to the accumulator •Only when 8 digits of overflow have occurred are we at risk of overflowing the accumulator. •By bounding the number of adds that are done to the accumulator we can guarantee against overflow.