Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fractions in Binary.

Similar presentations


Presentation on theme: "Fractions in Binary."— Presentation transcript:

1 Fractions in Binary

2 Fractions Binary doesn’t just do integers (whole numbers) it can also be used for fractions though it isn’t as accurate as decimals in denary e.g could be expressed as /2 + 1/4 /2 1/4 1/8 1/16 This is binary notation – the decimal point is in a fixed point

3 The problem Clearly with a limited number of places after the decimal point it is far less accurate as only a limited range of decimals can be displayed The number of extra places after the decimal point increase accuracy

4 Fixed point example 1 byte = 8 bits
If 4 bits were assigned after the decimal Place (this does not take up any bits) /2 1/4 1/8 1/16

5 Task Look at the table on page 195 showing binary fractions
Do questions 1-3 on page 196

6 So how do you represent all of the other decimals in binary?
Floating point binary

7 Floating Point Binary In decimal, you can use scientific notation for really big numbers e.g. 1,2,0000,0000,0000 Would be x 10 13 Exponent Which defines where to place the decimal point In this case move 13 places to the right Mantissa Which holds the digits

8 Floating Point Binary In binary, firstly bits are shared between the mantissa and the exponent In the example below, 2 bytes (16 bits) with 10 bits for the mantissa and 6 for the exponent Mantissa Exponent = x 2 Sign bit 3 This is a sign bit – if positive i.e. 0 move the decimal point right, if negative i.e. 1 move the decimal point left There is always an imaginary decimal here

9 Floating Point Binary Mantissa Exponent 0110100000 000011 = 0.1101 x 2
= 110.1 = 6.5 in denary 3

10 Task Do Q4 on page196 Rules: Place the point between the sign bit and the first digit of the mantissa Convert the exponent to its decimal form (positive or negative) Move the point right if the exponent is positive or left if negative Convert the resulting binary number to denary

11 If the mantissa is negative
Mantissa Exponent would become ½ = = -1.5 Negative sign bit Move three places right Negative leftmost bit

12 What if the mantissa and exponent are negative?
Mantissa Exponent Move the point left and fill with 1’s as you do so: 1.111 =

13 Task Do question 5 on page 197

14 Normalisation In order to get the most accurate representation possible with a given size of mantissa, no zeros should be put to the left of the most significant bit (not including the sign bit) E.g. in decimal: x10 would be normalised to x10 A binary number in normalised form will have the first bit of the mantissa not including the sign bit as a 1 9 8

15 To normalise a number in binary
put in the binary point and convert the exponent to decimal: Exponent 2 Move the number to the correct position and count the number of movements to the left to get the binary point before the first 1 required 3 left places Take 3 away from the exponent of 2: = -1 Convert -1 back to binary

16 To normalise a negative number in binary
With a negative number, the most significant bit not including the sign bit will be a 0 Shift the number left until the first bit (not the sign bit) is a zero then adjust the exponent

17 To normalise a negative number in binary
put in the binary point and convert the exponent to decimal: Exponent 3 Move the number to the correct position and count the number of movements to the left to get the binary point before the first 0 required 4 left places Take 4 away from the exponent of 3: = -1 Convert -1 back to binary

18 Task Do question 6 and 7 on page 198 Read the hint on page 198
Do exercises on page 199


Download ppt "Fractions in Binary."

Similar presentations


Ads by Google