Objectives Today: P4 Data Types – Floating Points P4 Variable Quiz P3 Iteration and Selection Practical Are you logged on? Then come around the table Unit 6 Software Development Assignment 1
Quiz? Folks, discuss in pairs the following questions and write your answers down on the worksheet. (2 mins) What are integers? (2 points) What is a bit? (2 points) How many bits in a byte? (2 points)
What do you remember from yesterday? Do Floating Points include? 1. A Fraction system 2. Use of bytes Which of these are used to create the floating point? MRT Engagement Mantissa Expurgator Mantisigator Exponent
What is a Floating Point? How many bits are in 2 bytes? Answer: 16 bits. We can use many bytes to hold numbers especially very large numbers. Work out the following using 1 byte? Convert 136 to binary 128 ¦ 64 ¦ 32¦ 16 ¦ 8 ¦ 4 ¦ 2 ¦ 1 (5 points) 1 1
How to represent fractions? Next problem… The number 136.75 is the equivalent to 136 + 1/2 and 1/4 1 / 2 = 0.5 (1/2) 1 / 4 = 0.25 (1/4) 1/8 = 0.125 (1/8) 1/16 = 0.0625 (1/16) Convert 136.75 in to binary 128 ¦ 64 ¦ 32¦ 16 ¦ 8 ¦ 4 ¦ 2 ¦ 1 . 1/2 ¦ 1/4 ¦ 1/8 ¦ 1/16 What is the binary representation of .75? (5 points) 1 0 0 0 1 0 0 0 . 1 1 0 0
This is a very big number! 1,200,000,000,000.00000000000001 Another purpose of a floating point is to represent numbers of different magnitudes (sizes) and help maintain the accuracy of the number. This involves the use of many bytes. Physicists will use huge numbers in their calculations where as a microchip designer will need accuracy (1/10 of a millimetre is crucial).
Memory Since computer memory is limited (only so many ‘storage-cells’) when storing data, there is a limitation on the number of digits to represent real numbers. An example: is 3.456 the same as 3.45? Answer: 32 Bits How many bits in 4 bytes? 1st byte 128 64 32 16 8 4 2 1 2nd byte 32768 16384 8192 4096 2048 1024 512 256 What is the largest number represented by 32 bits that you can remember - maintain the accuracy of the number (every digit must be correct)? 3rd byte 8388608 4194304 2097152 1048576 524288 262144 131072 65536 4th byte 2147483648 1073741824 536870912 268435456 134217728 67108864 33554432 16777216
Single and Double Precision What is a single and a double? Single – a number with a decimal part. Double is a much bigger number with a decimal part. Format Total bits Significand bits Exponent bits Smallest number Largest number Single precision 7 significant digits 32 23 + 1 sign 8 1.2 x 10-38 3.4 x 1038 Double precision 14 significant digits 64 52 + 1 sign 11 5.0 x 10-324 1.8 x 10308
Floating Points in our Decimal System In decimal we can display large numbers as a MANTISSA and an EXPONENT 1,200,000,000,000 can be written as 0.12 X 1013 0.12 is called the mantissa and 1013 is the exponent Holds the digits and the exponent defines where to place the decimal point The decimal point has been moved 13 places to the left.
Floating Point in our Binary System The same techniques can be used for binary numbers 2 bytes (16 bits) can be divided into 10 bits for the mantissa (1 sign bit and 9 digits) and 6 bits for the exponent. Mantissa (10 bits) 0 . 110100000 Exponent (6 bits) 000011 Sign shows whether the number is positive (0) or negative (1)
Floating Point in our Binary System Let’s see what is happening with the Exponent… We can work out what the exponent is in denary 32 16 8 4 2 1 0 0 0 0 1 1 We can work out the exponent equals the number? 2 + 1 = 3
Floating Point in our Binary System Let’s use the exponent (which we know is 3) on the mantissa We move the binary point three places to the right; the number now becomes 110.1 which is… 30 seconds convert this binary number in to denary ¦ 4 ¦ 2 ¦ 1 . ½ ¦ ¼ 0110 . 100000 01 . 10100000 0 . 110100000 011 . 0100000
Quiz – what is the correct answer? Is the number 3.5 6.75 8 ¦ 4 ¦ 2 ¦ 1 . ½ ¦ ¼ 8.5 6.5 0110 . 10000 4 + 2 +0.5 = 12.75 0.5
Convert the following binary numbers to denary 0 . 101010000 000010 0 . 110110000 000100 Exponent is 2 010 . 1010000 Answer is 2 + .5 + .125 = 2.625 Exponent is 4 01101.10000 Answer is 8 + 4+ 1 + .5 = 13.5
Summing Up Quiz Why are Floating points used? Represent fraction system Represent large numbers What are floating points made up of? Mantissa with 1 sign bit Exponent How are these parts used? Mantissa holds the digits representing the number Determines where the binary point needs to be placed
Use your answers Yippee!! Use your answers to write up how floating points are used for Assignment 1 Task 4. Print off this assignment for marking. Yippee!!