Docsity

Understanding Number Representation and Errors in Computing - Prof. David M. Rocke, Study notes of Engineering

Partial preview of the text

Download Understanding Number Representation and Errors in Computing - Prof. David M. Rocke and more Study notes Engineering in PDF only on Docsity!

EAD 115

Numerical Solution of Engineeringand Scientific Problems^ David M. Rocke^ Department of Applied Science

Computer Representation of

Numbers

-^ Counting numbers (unsigned integers) arethe numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11, … •^ In almost all computers, these numbersare represented in binary (base 2) ratherthan decimal. •^ We count 0, 1, 10, 11, 100, 101, 110, 111,1000, 1001, …

Fixed length Integers • Data storage is generally in bytes, where 1byte = 8 bits. • With one-byte integers, the smallestinteger that can be stored is 0, and thelargest is 11111111

8 = 2–^ 1 = 255. 2

-^ Internet IP addresses consist of four bytes,so that no part of an IP address exceeds255 (UC Davis is 168.150.243.2).

-^ The IP address 168.150.243.2 looks like this inbinary:

10101000100101101111001100000010

Application: Digital Audio • Uncompressed digital audio can berepresented as a sequence of loudnesslevels • A pure tone has a sequence that evolve asa sine wave • The loudness levels can be representedas unsigned integers, giving all possiblevalues

Pure Tone

Sampling Rate

-^ The sampling rate is the number of timesper second that a loudness measure istaken •^ CD’s are 44,100 times per second (44.1MHz) •^ Digital recordings are typically 44.1, 48,96, or 192 MHz

Word Length

-^ 8-bit audio has loudness levels that exist^8 in 2= 256 discrete levels. This is crude •^ 16-bit audio has 2

16 = 65,536 loudness levels. This is what is used for CD’s • Audio is often now recorded in 24-bitaudio, which has 16,777,216 levels, and isdifficult to distinguish from the smoothoriginal

Pure Tone with no Headroom

  • Signed integers 16 bit signed integers can representany whole number from -32,767 to32,

Decimal Numbers • Decimal numbers or floating point (vs.fixed point) are represented in scientificnotation. • 1,437,526 = .1437526×

7

-^ Exponent +7 mantissa +1437526 •^ We represent this in binary on a computer

-^ Typical single/double precision:^ –^ 1 sign bit^ –^ 8/11 exponent bits (one sign)^ –^ 23/52 bit mantissa

Smallest Positive Number • Sign 0 (positive) • Exponent sign 1 (negative) • Exponent magnitude 11 (3 in decimal) • Mantissa, smallest normalized is 100 (nextsmallest is 011 which has a leading 0). • 100 represents 2

-1^ =0.5 in decimal.

-^ Smallest positive number is 2

-4^ = 1/

-^ If we divide this by 2 we get 0 (underflow)!