floating point representation

29
box 1 A normalised floating point representation uses an 8-bit mantissa and a 4-bit exponent, both stored using two’s complement format. (a) In binary, write the largest positive number that can be represented using this normalised floating point system in the boxes below. Mantissa Exponent (1 mark) (b) This is a floating point representation of a number. 1 0 0 1 1 0 0 0 0 0 1 1 Mantissa Exponent Calculate the denary equivalent of the number, showing how you have arrived at your answer. Working: .............................................................................................................................. ............................................................................................................................................ ............................................................................................................................................ Answer: ............................................................................................................................... (2 marks) (c) Write the normalised floating point representation of the denary value 13.625 in the boxes below. Space has been provided for you to do rough work. Rough Work: ...................................................................................................................... ............................................................................................................................................ ............................................................................................................................................ Answer: Mantissa Exponent (2 marks)

Upload: edgardo-leysa

Post on 16-Nov-2015

73 views

Category:

Documents


6 download

DESCRIPTION

Floating Point Representation

TRANSCRIPT

  • box

    1 A normalised floating point representation uses an 8-bit mantissa and a 4-bit exponent, both stored using twos complement format.

    (a) In binary, write the largest positive number that can be represented using this normalised floating point system in the boxes below.

    Mantissa Exponent

    (1 mark)

    (b) This is a floating point representation of a number.

    1 0 0 1 1 0 0 0 0 0 1 1

    Mantissa Exponent

    Calculate the denary equivalent of the number, showing how you have arrived at your answer.

    Working: ..............................................................................................................................

    ............................................................................................................................................

    ............................................................................................................................................

    Answer: ...............................................................................................................................(2 marks)

    (c) Write the normalised floating point representation of the denary value 13.625 in the boxes below. Space has been provided for you to do rough work.

    Rough Work: ......................................................................................................................

    ............................................................................................................................................

    ............................................................................................................................................

    Answer:

    Mantissa Exponent

    (2 marks)

  • (d) Write the normalised floating point representation of the denary value 0.34375 in the boxes below. Space has been provided for you to do rough work.

    Rough Work: ......................................................................................................................

    ............................................................................................................................................

    ............................................................................................................................................

    Answer:

    Mantissa Exponent

    (2 marks)

    (e) Explain what overflow is and give an example of a situation which might cause overflow to occur.

    ............................................................................................................................................

    ............................................................................................................................................

    ............................................................................................................................................

    ............................................................................................................................................

    ............................................................................................................................................(3 marks)

  • 2 A normalised floating point representation uses an 8-bit mantissa and a 4-bit exponent, both stored using twos complement format.

    (a) In binary, write in the boxes below, the smallest positive number that can be represented using this normalised floating point system.

    Mantissa Exponent(2 marks)

    (b) This is a floating point representation of a number:

    Mantissa Exponent

    1 0 1 1 0 0 0 0 0 0 0 1

    Calculate the denary equivalent of the number. Show your working.

    Working: ..............................................................................................................................

    ............................................................................................................................................

    ............................................................................................................................................(1 mark)

    Answer: ...............................................................................................................................(1 mark)

    (c) Write the normalised floating point representation of the denary value 12.75 in the boxes below. Space has been provided for you to do rough work, if required.

    Rough Work: .....................................................................................................................

    ............................................................................................................................................

    ............................................................................................................................................

    Answer:

    Mantissa Exponent(2 marks)

  • (d) Floating point numbers are usually stored in normalised form.

    State two advantages of using a normalised representation.

    Advantage 1: ......................................................................................................................

    ............................................................................................................................................

    Advantage 2: ......................................................................................................................

    ............................................................................................................................................(2 marks)

    (e) An alternative twos complement format representation is proposed. In the alternative representation 7 bits will be used to store the mantissa and 5 bits will be used to store the exponent.

    Existing Representation (8-bit mantissa, 4-bit exponent):

    Mantissa Exponent

    Proposed Alternative Representation (7-bit mantissa, 5-bit exponent):

    Mantissa Exponent

    Explain the effects of using the proposed alternative representation instead of the existing representation.

    ............................................................................................................................................

    ............................................................................................................................................

    ............................................................................................................................................

    ............................................................................................................................................

    ............................................................................................................................................

    (2 marks)

  • 3 A normalised floating point representation uses a 7-bit mantissa and a 5-bit exponent, both stored using twos complement format.

    (a) In binary, write the most negative number that can be represented using this normalised floating point system in the boxes below:

    (2 marks)

    (b) This is a floating point representation of a number:

    Calculate the denary equivalent of the number. Show how you have arrived at your answer.

    Working: ..............................................................................................................................

    ............................................................................................................................................

    ............................................................................................................................................(1 mark)

    Answer: ...............................................................................................................................(1 mark)

    (c) Write the normalised floating point representation of the denary value 416 in the boxes below. Show how you have arrived at your answer.

    Working: .............................................................................................................................

    ............................................................................................................................................

    ............................................................................................................................................(1 mark)

    Answer:

    (1 mark)

    Mantissa Exponent

    Mantissa Exponent

    1 0 1 0 1 0 0 0 0 1 1 0

    Mantissa Exponent

  • (d) Write the normalised floating point representation of the negative denary value -12.5 in the boxes below. Show how you have arrived at your answer.

    Working: .............................................................................................................................

    ............................................................................................................................................

    ............................................................................................................................................

    ............................................................................................................................................(2 marks)

    Answer:

    (1 mark)

    (e) Table 4 lists three different calculations that might cause an error to occur in a floating point system.

    Complete Table 4 by stating the name of the type of error that may occur for each calculation. You should not give the same answer more than once.

    Table 4

    Calculation Type of error

    Multiplying two very large numbers together.

    Dividing a number by a very large number.

    Adding together two numbers of very different sizes eg a tiny number to a very big number.

    (3 marks)

    Mantissa Exponent Mantissa Exponent

  • 4 A particular computer uses a normalised floating point representation with an 8-bit mantissa and a 4-bit exponent, both stored using twos complement.

    (a) Four bit patterns that are stored in this computers memory are listed in Figure 3 and are labelled with the letters A to D. Three of the bit patterns are valid floating point numbers and one is not.

    Figure 3

    A 0 1 0 0 0 0 0 0 1 0 0 0

    Mantissa Exponent

    B 0 1 0 0 0 0 0 0 1 1 1 1

    Mantissa Exponent

    C 0 0 1 0 1 0 0 0 0 1 1 0

    Mantissa Exponent

    D 1 0 1 0 1 0 0 0 0 1 0 1

    Mantissa Exponent

    Complete Table 1 below. In the Correct letter (A-D) column write the appropriate letter from A to D to indicate which bit pattern in Figure 3 is an example of the type of value described in the Value description column.

    Do not use the same letter more than once.

    Table 1

    Value description Correct letter (A-D)

    A negative value.

    The smallest positive value that can be represented.

    A value that is not valid in the representation because it is not normalised.

    (3 marks)

  • (b) This is a floating point representation of a number.

    0 1 0 1 0 0 0 0 0 1 1 0

    Mantissa Exponent

    Calculate the denary equivalent of the number. Show how you have arrived at your answer.

    Working: .............................................................................................................................

    ............................................................................................................................................

    ............................................................................................................................................(1 mark)

    Answer: ..............................................................................................................................(1 mark)

    (c) Write the normalised floating point representation of the negative denary value -7.75 in the boxes below. Show how you have arrived at your answer.

    Working: .............................................................................................................................

    ............................................................................................................................................

    ............................................................................................................................................

    ............................................................................................................................................(2 marks)

    Answer:

    Mantissa Exponent

    (1 mark)

  • (d) There can be a loss of precision when a denary number is stored using this floating point system.

    The closest possible representation of the denary number 6.9 is shown below.

    0 1 1 0 1 1 1 0 0 0 1 1

    Mantissa Exponent

    By converting this bit pattern back into denary it can be seen that the actual number stored is 6.875, not 6.9.

    (d) (i) Calculate the absolute error that has occurred.

    ............................................................................................................................................

    ............................................................................................................................................(1 mark)

    (d) (ii) Calculate the relative error that has occurred.

    ............................................................................................................................................

    ............................................................................................................................................(1 mark)

    (d) (iii) Explain how the floating point system used could be modified to allow a more accurate representation of 6.9.

    ............................................................................................................................................

    ............................................................................................................................................

    ............................................................................................................................................(2 marks)

  • 5 A particular computer uses two 8-bit bytes to store floating-point values. One byte is used to store the mantissa and the other is used to store the exponent.

    (i) Write down, in binary form, the largest positive value that can be stored using this representation.

    [2]

    (ii) Write down, in binary form the smallest magnitude, negative number that can be stored in this representation.

    [2]

    (iii) The value 01101000 11111101 is stored as a floating-point number in this computer.

    State what denary number is being represented, explaining how you arrived at your answer.

    [4]

  • 6 A particular computer uses a single 10-bit word to store a floating-point representation of a number.

    The first 6 bits are used to store the mantissa and the remaining 4 bits are used to store the exponent.

    (i) Explain why 000101 0100 = 21

    2 using this notation.

    [2]

    (ii) Rewrite the binary value of this floating-point representation so that it is in normalised form.

    [2]

    (iii) 011001 0011 is a normalised floating-point number.

    By converting each of the mantissa and the exponent into a denary number first, write this number in denary.

    [3]

  • 7 Floating point is to be used to represent real numbers with:

    8 bits for the mantissa, followed by

    4 bits for the exponent

    twos complement used for both the mantissa and the exponent

    (i) Consider the binary pattern:

    0 1 1 0 1 0 0 0 0 1 0 0

    What number is this in denary? Show your working.

    [3]

    (ii) The representation shown in part (d)(i) is normalised.

    Explain why floating point numbers are normalised.

    [1]

    (iii) Show the binary pattern for the smallest positive number which can be stored using a normalised 12-bit floating point representation.

    Mantissa:

    Exponent:

    Work out its denary value.

    Denary: [3]

  • (b) The developer of a new programming language decides that all real numbers will be stored using 20-bit normalised floating point representation. She cannot decide how many bits to use for the mantissa and how many for the exponent.

    Explain the trade-off between using either a large number of bits for the mantissa, or a large number of bits for the exponent.

    [2]

  • Real numbers are to be stored in floating point representation with:

    8 bits for the mantissa, followed by

    4 bits for the exponent

    twos complement used for both the mantissa and the exponent

    (i) Consider the binary pattern:

    1 0 1 0 1 0 0 0 0 1 1 1

    What number is this in denary? Show your working.

    [3]

    (ii) Explain how you can recognise that the above pattern is normalised.

    [1]

    (iii) Show the binary pattern for the smallest negative number (negative sign and large magnitude) which can be stored using a normalised 12-bit floating point representation.

    Mantissa:

    Exponent:

    Work out its denary value.

    Denary: [3]

    8

  • 9 Many computer systems need to store and process real numbers.

    A computer uses two bytes to store a real number. The first (Byte 7) stores the mantissa and the second (Byte 8), the exponent. Both mantissa and exponent use twos complement.

    (i) What denary number is represented by Byte 7 and Byte 8?

    Byte 7 Byte 8

    0 1 1 0 1 0 0 0 0 0 0 0 0 0 1 1

    Show your working.

    [3]

    (ii) Without any working out, how can you recognise that this 16-bit pattern (Byte 7 and Byte 8) is a positive number?

    [1]

    (b) (i) Without any working out, how can you recognise that this 16-bit pattern (Byte 7 and Byte 8) is normalised?

    [1]

    (ii) Both of the representations shown below are not normalised.

    Write in the empty rows the binary for the normalised form for the same value.

    Mantissa Exponent

    0 0 1 1 0 0 0 0 0 0 0 0 1 0 1 1

    Mantissa Exponent

    1 1 1 0 0 0 1 1 0 0 1 1 0 0 1 1

    [3]

    (a)

  • (c) A change is made to use the two bytes as a 12-bit mantissa with a 4-bit exponent. Describe the effect of this change on the values that can be represented, compared with the old use of the two bytes.

    [2]

  • 10 Many computer systems need to store and process real numbers.

    A computer uses two bytes to store a real number. The first (Byte 1) stores the mantissa and the second (Byte 2) the exponent. Both mantissa and exponent use twos complement.

    (i) What denary number is represented by Byte 1 and Byte 2?

    Byte 1 Byte 2

    1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1

    Show your working.

    [3]

    (ii) How can you recognise that this 16-bit pattern (Byte 1 and Byte 2) is normalised?

    [1]

    (iii) The positive number 2.0 is to be represented as a normalised real number.

    Show the mantissa and exponent for this value.

    Mantissa Exponent

    [2]

    (iv) What is the largest positive number that can be represented? Use the same 8-bit mantissa and 8-bit exponent.

    Show the mantissa and exponent.

    Mantissa Exponent

    Do not attempt to evaluate this. [2]

  • (b) An alternative representation is suggested using a 6-bit mantissa with a 10-bit exponent. Describe the effect on the numbers which can be represented, compared to the 8-bit mantissa and 8-bit exponent used earlier.

    [2]

  • 1

    1 mark for correct bit pattern in both mantissa and exponent. 1

    (b) Mantissa = -0.6875 // -11/16 Exponent = 3 Answer = -5.5 // -5

    1 method mark for either: showing correct value of both mantissa and exponent in

    denary showing binary point shifted 3 places to right within a

    correct binary pattern* indicating that final answer calculated using

    answer = mantissa x 2exponent (A mantissa in denary or binary but exponent must be in denary)

    1 mark for correct answer

    * Correct binary patterns with the binary point shifted 3 places are:

    1010.1000 0101.1000 1010.1 101.1000 101.1 2

    (c)

    1 mark for correct mantissa 1 mark for correct exponent 2

    (d)

    1 mark for correct mantissa 1 mark for correct exponent 2

    0 1 1 1 1 1 1 1 0 1 1 1

    Mantissa Exponent

    0 1 0 1 1 1 1 0 0 1 0 0

    Mantissa Exponent

    0 1 1 0 1 0 0 0 1 1 1 1

    Mantissa Exponent

    (a)

  • (e) Definition (2 marks): The result of a calculation is too large to store/represent // a number is too large to store/represent; In the available number of bits / storage space (allow example e.g. data type, byte, word, example of a data type); R space NE

    Example (1 mark): Multiplying two numbers together; Dividing a number by a number less than one / small number; R zero A Adding two numbers (of same sign) A When number converted from one type to another that does not have suitable range/enough bits/enough storage space to represent it A Answers by example MAX 1 3

  • 2

    1 mark for correct mantissa 1 mark for correct exponent 2

    (b) 1 method mark for either: showing correct value of both mantissa and exponent in

    denary showing binary point shifted 2 places to right in binary number indicating that final answer calculated using

    answer = mantissa x 2exponent1 mark for correct answer [ Mantissa = -0.625 // -5/8 Exponent = 2 Answer = -2.5 // -2 2

    (c)

    1 mark for correct mantissa 1 mark for correct exponent 2

    (d) Maximises precision/accuracy for given number of bits; Note: Must have concept of given number of bits or an example of this e.g. word length.

    Unique representation of each number // simpler to test for equality of numbers; 2

    (e) Reduced precision; Increased range; A can represent larger/smaller numbers No effect on amount of memory required to represent a number;

    Max 2

    0 1 0 0 0 0 0 0 1 0 0 01

    Mantissa Exponent

    0 1 0 1 0 1 0 1 0 1 0 0

    Mantissa Exponent

    (a)

  • 3 (a)

    1 mark for correct mantissa1 mark for correct exponent 2

    (b) 1 method mark for either:

    showing correct value of both mantissa and exponent in denary

    showing binary point shifted 6 places to right in binary number

    indicating that final answer calculated using answer = mantissa x 2exponent

    Mantissa = -0.6875 // -11/16Exponent = 6Answer = -44

    1 mark for correct answer

    If answer is correct and some working has been shown, award two marks, even if working would not have gained credit on its own.Marks for working can be awarded in the answer. 2

    (c) 1 mark for working:

    Showing a bit pattern including 1101 and any number of preceding or following 0s, but no other 1s;Showing the correct value of the exponent in denary (9);Showing the binary point being shifted 9 places;MAX 1

    1 mark for correct mantissa and exponent together:

    If answer is correct and some working has been shown, award two marks, even if working would not have gained credit on its own.Marks for working can be awarded in the answer. 2

    0 1 01 1 0 00 1 0 10

    Mantissa Exponent

    1 0 00 0 0 0 0 1 111

    Mantissa Exponent

    1

  • (d) 2 marks for working:

    Correct representation of 12.5 in fixed point binary: 1100.1; Bits flipped: 0011.0 // 10011.0; A any number of preceding 1sCorrect representation of -12.5 in fixed point twos complement: 10011.1; A any number of preceding 1sShowing the correct value of the exponent in denary (4) or binary // showing the binary point being shifted four places;Showing the correct value of the mantissa in floating point binary (1.001110)

    MAX 21 mark for correct mantissa and exponent together:

    If answer is correct and some working has been shown, award three marks, even if working would not have gained credit on its own.Marks for working can be awarded in the answer. 3

    (e)Calculation Type of

    Error

    Multiplying two very large numbers together. Overflow;

    Dividing a number by a very large number. Underflow;

    Adding together two numbers of very different sizes e.g. a tiny number to a very big number.

    Cancellation;

    If same answer is used more than once and it is correct in one instance then award the mark for the correct instance. 3

    1 0 10 1 1 00 0 1 00

    Mantissa Exponent

  • 4 (a) One mark per correct answer:

    Value description Correct letter (A-D)A negative value. D; The smallest positive value that can be represented.

    A;

    A value that is not valid in the representation because it is not normalised.

    C;

    If a letter is used more than once then mark as correct in the position that is correct.

    3

    (b) 1 method mark for either: showing correct value of both mantissa

    and exponent in denary showing binary point shifted 6 places to

    right in mantissa indicating that final answer calculated

    using answer = mantissa x 2exponent

    Mantissa = 0.625 // 5/8 Exponent = 6

    1 mark for correct answer

    Answer = 40

    If answer is correct and some working has been shown, award two marks, even if working would not have gained credit on its own.

    2

  • (c) 2 marks for working:

    Correct representation of 7.75 in fixed point binary: 111.11; A. leading and trailing 0s. Bits flipped: 000.00 // 1000.00; A. leading 1s Correct representation of -7.75 in fixed point twos complement: 1000.01; A. leading 1s Showing the correct value of the exponent in denary (3) or binary (11) // showing the binary point being shifted 3 places;

    Note: Award both working marks if bit pattern 1.00001 is shown anywhere

    MAX 2

    1 mark for correct mantissa and exponent together:

    If answer is correct and some working has been shown, award three marks, even if working would not have gained credit on its own.

    Working marks can be awarded for work seen in the final answer e.g. correct exponent.

    3

    (d) (i) 0.025 // 6.9-6.875 // 1/40 R. -0.025 A. award BOD mark if correct method has been shown i.e. 6.9-6.875 but candidate has then made an error performing the subtraction operation

    1

    (d) (ii) 0.003623 // 0.025/6.9 // 1/276 A. 0.3623% A. answers rounded to at least two significant figures A. follow-through of incorrect answer to part 2di A. award BOD mark if correct method has been shown but candidate has then made an error performing the division operation R. if shown that incorrect method used e.g. dividing by 6.875, even though this arrives at an answer that is the same when written to 2 significant figures

    1

    1 0 0 0 0 1 0 0

    0 0 1 1

    Mantissa

    Exponent

  • (d) (iii) Alternative 1: Adjust the mantissa; To use more bits; A. "longer" for "more bits" but R. "larger", "increase size" Alternative 2: Reallocate (one) bit; from the exponent to the mantissa; A. bitsAlternative 3: Infer one of the two bits on either side of the binary point (from the other, as they must both be different); use the freed up bit to store one more significant digit in the mantissa// use the freed up bit to represent mantissa more accurately;

    2

  • 5 (1 per nybble) [3]

    (i) 01111111 01111111 (1 per byte) [2]

    (ii) 11111111 10000000 OR 10111111 10000000 (1 per byte) [2]

    (iii) 11111101 = 128 +(64+32+16+8+4+1) = 3 01101000 = + + 1/16 = 13/16 Number represented = 13/16 * ^3 {1/8} = 13/128 (or .1015625) OR: 11111101 = 128 +(64+32+16+8+4+1) = 3 (01101000 = 0.1101) = 0.1101 * 2^3 = 0.0001101 = 1/16 + 1/32 + 1/128 = 13/128

    Accept mantissa: 3/128 exponent: +104

    (1 per line, max 4) [4]

    (i) = (1/8 + 1/32) * 2^4 = 5/32 *16 = 2 OR: = 0.00101 * 2^4 Hence move point 4 places = 10.1 = 2 1/2 (1 mark for each underlined section, max 2. Note: Accept decimal values) [2]

    (ii) 010100 0010 (1 for mantissa, 1 for exponent) [2]

    (iii) M = + + 1/32 OR = 25/32 E = 3 Number is 25/32 * 8 = 6 (1 per line, max 3) [3]

    6

  • (i) +13 mark as follows: Exponent: +4 // move the pattern four places Mantissa: +13/16 // 0.1101 Answer: 13/16 24 // or equivalent [3]

    (ii) There will be a unique representation for a number The format will ensure the number is represented with the greatest possible/more accuracy/precision Multiplication is performed more accurately/precisely [MAX 1]

    (iii) Mantissa: 0100 0000 Exponent: 1000 Therefore number is * 28 // +1/512 // +29 // 0.00195 [3]

    (b) choices made will effect range and accuracy More bits used for the mantissa will result in better accuracy More bits use for the exponent will result in larger range of numbers [Max 2]

    7

    (i) 88 mark as follows: Exponent: +7 // move pattern 7 places Mantissa: 11/16 // 1.0101 Answer: 11/16 27 // or equivalent [3]

    (ii) The mantissa/the binary pattern starts with 10 // the first two bits of the mantissa/the binary pattern are different [1]

    (iii) Mantissa: 1000 0000 Exponent: 0111 Denary: 128 // 27 // 1 * 27 [3]

    8

    (a)(i) +6.5 give 3 marks If answer incorrect mark as follows: Exponent: +3 // move the pattern three places Mantissa: +13/16 // 0.1101

    Answer: 13/16 23 // or equivalent [3]

    (ii) (Positive ) The mantissa/byte 7 starts with a zero [1]

    (b)(i) (Normalised ) The mantissa/byte 7 starts with 01 / the first two bits are different [1]

    (ii) Mantissa Exponent

    0 1 1 0 0 0 0 0 0 0 0 0 1 0 1 0

    Mantissa Exponent

    1 0 0 0 1 1 0 0 0 0 1 1 0 0 0 1 [MAX 3]

    (c) The precision / accuracy is increased, but The range of possible numbers is decreased [2]

    9

  • (a) (i)1.75 give 3 marks If answer incorrect mark as follows: Exponent: +1 // move the pattern one place Mantissa: 7/8

    Answer: 7/8 21 // or equivalent [3]

    (ii) The mantissa starts with a 10 ... [1]

    (iii) 2.0 normalised Mantissa Exponent

    0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0

    [2]

    (iv) Mantissa Exponent

    0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1

    Mantissa (1) Exponent (1) [2]

    (b) The precision/accuracy is decreased, but The range of possible numbers is increased [2]

    10

    Blank PageBlank Page