














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An introduction to number representation in computing for engineers, including precision and accuracy considerations. Topics covered include binary, integer, and real number representation, as well as limitations and standards. Students are encouraged to explore online resources for further learning.
Typology: Study notes
1 / 22
This page cannot be seen from the preview
Don't miss anything!















1
(aka: fixed vs floating point numbers) • IEEE Floating Point • How Matlab handles this
Good Accuracy^ Poor Precision
Poor Accuracy Poor Precision
-^ Low precision:
π^ = 3.
-^ High precision:
π^ = 3.
-^ Low accuracy:
π^ = 3.
-^ High accuracy:
π^ = 3.
-^ High accuracy & precision:
π^ = 3. In most cases, computers must deal with finite precision(some software provides unlimited precision).
-^ A byte is the smallest memory allocation available. •^ A byte contains 8 bits so that:^ – Smallest: 0 0 0 0 0 0 0 0 = 0 7
10
_4 32 1 +12+12+12+1_**
0 8 = 255(or 2^ -1)^10
-^ Result: a single byte can be used to store an integer numberranging from 0 to 255
(256 different numbers)
-^ If negative numbers are included, one bit must be dedicated to thesign, leaving only 7 bits for the number^ – Smallest: 0^ – Largest: +
or -128^10
-^ Two’s Complement has no negative zero; for a onebyte integer:^ –^ 01111111 = 127,^ –^ 00000001 = 1,^ –^ 00000000 = 0,^ –^ 11111111 = - 1,^ –^ 10000000 = -128 •^ Range: [ -128, 127 ] 10
Other languagesuse differentnames! Size^ Precision
Matlab^
Java (^8) 1 byte 2 = 256 uint8, int*^
byte 2 byte^ 65,
uint16, int*
short 4 byte^ 4,294,967,
uint32, int*^
int (^64) 8 byte 2 --^ long
(^0) Positive numbers smaller than 2
) Positive numbers greater-52^1023 than (2-2) x 2^ ( positive overflow, Matlab“realmax” ) Negative numbers less than -(2-
-52^1023 ) x 2^ Negative numbers-1022greater than -2^ ( negative underflow ( negative overflow ) )
Zero^ (actually is a specialcombination of bits) RESULT : about 16 digits of precision in the range ±
±
Others sources of error in computation: • Errors in the input data - measurement errors, errors^ introduced by the conversion of decimal data to binary,^ roundoff errors. • Roundoff errors during computation (as discussed) • Truncation errors - using approximate calculation is inevitable^ when computing quantities involving limits and other infinite^ processes on a computer^ – Never try to compare two floating point numbers for equality because all^ 16+ digits would have to match perfectly…^ – Use Matlab routi 14
nes whenever possible (they are optimized to avoid truncation and roundoff^ problems)
17
-^ In the previous slide, we see: •^ What is the size of the variable “
i”
-^ What does “class
” represent? Name^ • How many bytes are used to store the value? Size^
Bytes^ Class i^ 1x^
8 double^ array s^ 1x^
86 char^ array t^ 1x
1600
double^ array
-^ Describe memory. List different kinds of memory. •^ What is IEEE 754? Describe how MATLAB representsnumbers. •^ Draw a number line and identify ranges where computerswill generate errors. •^ Describe three potential sources of errors incomputation. •^ Describe precision. Describe accuracy. •^ Describe how we can protect ourselves fromcomputation error. 19
20
Action Items • Review the lecture • How will you use this informationin your current work? … futurework at GT? • Start Exploring Matlab! • Increment your record ofcommands learned • Come prepared to ask questionsabout MATLAB Lecture Outline • Numbers in the Computer • Precision and Accuracy