Errors and rounding. How tall are you? What is that in centimetres? So how tall are you in...
-
Upload
sibyl-wilkinson -
Category
Documents
-
view
212 -
download
0
Transcript of Errors and rounding. How tall are you? What is that in centimetres? So how tall are you in...
UNIT 18: COMPUTATIONAL THINKING
Errors and rounding
Errors
How tall are you? What is that in centimetres? So how tall are you in millimetres? Margin of error Sometimes acceptable What happens when we start doing operations
though?
Rounding
0 0.5 1.0
Move number to nearest ‘significand’ Easy. What about 0.5?
Round-up Round to even, statistician’s rounding,
banker’s rounding Rounding towards zero (truncating)
Petrol prices
Do these calculations using the prices corrected to the nearest penny. How much do motorists pay for petrol in Hereford? Petrolprices.com take an average of the three prices
given. If we have a 60 litre tank, how much does it cost to fill it?
(Assume it is empty to start). What if we used ‘super’ to fill the same tank? What is the
difference? What if we used diesel to fill the same-size tank? What is
the difference?
Now repeat the calculations but don’t correct the prices.Are your results the same?
Fractional numbers
How do you store a fraction in a computer?
½ easy = 0.5
1/3 more difficult = 0.33333333333333333…33
How many bits are allocated (allowed) for one number? If no limit could use all of a computers memory on one fraction!
Fractional numbers
Most computers use IEEE standard for ‘floating point numbers’
Provides a way to store fractions in the space of an 8- byte number
But, for most numbers it involves an approximation ‘rounding’ “correct” number
to nearest whole number X decimal places X significant figures
‘truncation’ just cut number off at specified limit
Floating point
Whole numbers = (x*1 + x*2+x*4+x*8+x*16etc)
Can store any whole number Fractions =
(x*1/2+x*1/4+x*1/8+x*1/16etc) How would you convey 1/10?
Computers work to 15 decimal places.
Division by zero
Division = sharing Divide these 50 marbles betweenthese 5 buckets
Division by zero Division = sharing Divide these 50
marbles betweenthese buckets:
Division by zero Division by zero crashes
programmes In spreadsheets it returns ‘error’
messages
Overflow and Underflow
Overflow Calculation returns value too large for
storage location Too much memory is being used or required
Underflow Calculation returns a value which is too small
(ie too close to zero) {fractions are tricky} Flush to zero Gradual underflow; subnormal numbers
User error!
88% of spreadsheets have errors Research: Bad math rampant in
family budgets and Harvard studies http://
www.marketwatch.com/story/88-of-spreadsheets-have-errors-2013-04-17
European Spreadsheet Risks Interest Group
Peer review Software programs
User errors
Access this website: Eight of the worst spreadsheet blunders http://www.cio.com/article/131500/Eight_
of_the_Worst_Spreadsheet_Blunders?page=4&taxonomyId=3000
Take one of the stories: find out what happened explain it to the rest of the class what was the loss what was the lesson learnt?
Spreadsheets – quick lesson
Open excel Goto top left (A1) Enter 1 – copy value to 4 rows beneath Go to A1, go right 1 cell (B1) Enter 3 – copy value to 2 rows beneath Goto B4, enter 6, copy value to B5 Goto C1, enter “=A1/$B$1” Copy formula to C2 and C3
Spreadsheets..cont’d
Add the result of C1,C2 and C3 in your head
Note your answer Insert a row below row 3 Goto C4 Enter =sum(C1:C3) – is this the same as
your result? Who is correct?
More spreadsheets
Copy the formula from C3 to C5 Is the result as expected? Absolute vs relative referencing
User errors
These happen in the real world with major consequences! Financial loss (corporate level) Job loss (individual level)
Transcription Wrong sign Allowing access to wrong people, wrong version or at
wrong time Using formatting to hide data instead of removing it Adding too many zeros Cut and paste Incorrect data (typo, transcription error) Incorrect formula (typo, cut & paste)
Tasks
1. Convert to binary: 63, 15, 48, 7, 52
2. Convert from binary to decimal: 1101, 11001100, 0011001101, 10101010
3. Convert to hexadecimal from decimal via binary: 15, 18, 33, 61, 46
4. Find the errors in the spreadsheet5. Use the following example to explain
two’s complement:a) 11-63
b) 2-1 (use this to explain why we use it, rather than sign & magnitude) .