341 views

Uploaded by Shazz Angel

U6/P3

- BM Assignment Solutions
- 1.8.2 Relational Database Modeling
- 1.4.4 Assembly Language
- User-Defined Data Type
- Olevel Computer Science Notes (2210)
- Python3 Guide
- 1.4.2 the Fetch-execute Cycle
- Revision Notes Paper 3
- Lin Segel applied mathematics
- Computer science 9608
- User-Defined Data Types
- Computer Science 2210 XI Worksheet -Mock 2015.pdf
- Multivariable Chapter7
- Notes Logic Gate
- 9691-01 Revision Notes (Modified F451)
- 1.3.3 Logic Gates and Logic Circuits
- IGCSE Computer Science 0478 Notes 1.1.1 - 1.1.4
- Multiplying Floating Point Numbers
- o Level Computer Science
- A2 computer Science - Computer Networking Problems

You are on page 1of 24

COMPUTERSCIENCE/UPPER6/P3

Page 1

Note: The first 1 on the left hand side is in the 9 th position, therefore in a 8 bit

register, the 9th bit

Is simply removed. So you will then have 00000010 which is 2 in denary.

COMPUTERSCIENCE/UPPER6/P3

Page 2

For example, subtracting 5 from 15 is really adding 5 to 15, but this is hidden by the two'scomplement representation:

COMPUTERSCIENCE/UPPER6/P3

Page 3

NUMBERS

NOTE: SYLLABUS STARTS HERE

COMPUTERSCIENCE/UPPER6/P3

Page 4

A binary floating point number may consist of 2, 3 or 4 bytes; however the only ones you need to

worry about are the 2 byte (16 bit) variety. The first 10 bits are the Mantissa; the last 6 bits are the

exponent.

Just like the denary floating point representation, a binary floating point number will have a mantissa

and an exponent, though as you are dealing with binary (base 2)

NOTE: After the most significant bit, place the decimal point (in the

mantissa only)

COMPUTERSCIENCE/UPPER6/P3

Page 5

100.1

011.1

The number is -3.5

decimal.

denary

There are several stages to take when working out a floating point number in binary. In fact it is

much like a disco dance routine - known on this page as the Noorgat Dance, (you wont be tested on

name but it should help you to remember)

1. Sign - find the sign of the mantissa (make a note of this)

2. Slide - find the value of the exponent and whether it is positive or negative

COMPUTERSCIENCE/UPPER6/P3

Page 6

3. Bounce - move the decimal the distance the exponent asks, left for a negative

exponent, right for a positive

4. Flip - If the mantissa is negative perform twos complement on it

5. Swim - starting at the decimal point work out the values of the mantissa, going left,

then right. Now make sure you refer back to the sign you recorded on the sign move.

Lets try it out. We are given the following 16 bit floating point number, with 10 bits for the mantissa,

and 6 bits for the exponent. Remember the decimal point is between the first and second most

significant bits

The first action we need to perform is the sign, find out the sign of the mantissa

The second step in the Noorgat dance is the slide, we need to find the value of the exponent, that is

the last 6 bits of the number

So we know that the exponent is of size positive one and we will have to move

the decimal point

one place to the right.

The third step in the Noorgat dance is the bounce that is moving the decimal point of the Mantissa

the number of positions specified by the slide, which was one position to the right. Like so:

COMPUTERSCIENCE/UPPER6/P3

Page 7

The fourth step is the optional flip. Check back to the sign stage and see if the Mantissa is negative.

It isn't? Oh well you can skip past this stage then as we only flip the number if the mantissa is

negative.

The fifth and final step is the swim. Taking the mantissa on its own we can now work out the value of

the floating point number. Start at the centre and label each number to the left

on. The each number on the right

and so

and so on.

Work out the denary for the following, using 10 bits for the mantissa and 6 bits for the

exponent:

EX1) 0.001101000 000110

Answer :

1. Sign: the mantissa starts with a zero, therefore it is a positive number.

2. Slide: work out the value of the exponent

000110 = +6

3. Bounce: we need to move the decimal point in the mantissa. In this case the exponent was positive so

we need to move the decimal point 6 places to the right

0.001101000 -> 0001101.000

4. Flip: as the number isn't negative we don't need to do this

5. Swim: work out the value on the left hand side and right hand side of the decimal point

1+4+8 = +13 FINISHED!

COMPUTERSCIENCE/UPPER6/P3

Page 8

Answer :

1. Sign: the mantissa starts with a zero, therefore it is a positive number.

2. Slide: work out the value of the exponent

111111 It starts with a one therefore it is a negative number

000001 = -1

3. Bounce: we need to move the decimal point in the mantissa. In this case the exponent

was negative so we need to move the decimal point 1 place to the left

0.101000000 -> 0.0101000000

4. Flip: as the mantissa number isn't negative we don't need to do this

5. Swim: work out the value on the left hand side and right hand side of the decimal point

1/4 + 1/16 = +0.3125 FINISHED!

Answer :

1. Sign: the mantissa starts with a one, therefore it is a negative number.

2. Slide: work out the value of the exponent

000101 = +5

COMPUTERSCIENCE/UPPER6/P3

Page 9

3. Bounce: we need to move the decimal point in the mantissa. In this case the exponent was positive so

we need to move the decimal point 5 places to the right

1.011111010 -> 101111.1010

4. Flip: the mantissa is negative as noted in step one so we need to convert this number

101111.1010 -> 010000.0110

5. Swim: work out the value on the left hand side and right hand side of the decimal point

16+1/4+1/8 = -16.375 FINISHED!

Answer :

1. Sign: the mantissa starts with a one, therefore it is a negative number.

2. Slide: work out the value of the exponent

111101 It starts with a one therefore it is a negative number

000011 = -3

3. Bounce: we need to move the decimal point in the mantissa. In this case the exponent

was negative so we need to move the decimal point 3 places to the left. Watch carefully!

1.101000000 -> 1.111101000000

note that we placed extra ones on the front of the number.

Consider the exponent being negative and the mantissa positive, we would add

extra zeros on the front 0.01 * 2^-3 = 0.00001

If both are negative placing zeros in front of the mantissa would make it

positive!

Therefore we need to add extra ones to keep the mantissa negative

With the flip we'll lose these 'extra' ones

4. Flip: the mantissa is negative as noted in step one so we need to convert this number

COMPUTERSCIENCE/UPPER6/P3

Page 10

5. Swim: work out the value on the left hand side and right hand side of the decimal point

1/32+1/64 = -0.046875 Remember the number was negative! FINISHED!

Answer:

1. Sign: the mantissa starts with a one, therefore it is a negative number.

2. Slide: work out the value of the exponent

000011 = +3

3. Bounce: we need to move the decimal point in the mantissa. In this case the exponent was positive so

we need to move the decimal point 3 places to the right.

1.111111010 -> 1111.111010

4. Flip: the mantissa is negative as noted in step one so we need to convert this number

1111.1110100 -> 0000.000110

5. Swim: work out the value on the left hand side and right hand side of the decimal point

1/16+1/32 = -0.09375 Remember the number was negative! FINISHED!

You might also be asked to convert a denary number into its binary floating point equivalent.

1. work out the binary equivalent

2. work out how far to move the binary point (y)

COMPUTERSCIENCE/UPPER6/P3

Page 11

3. set the exponent to be reverse of the number of places you moved the binary point (y)

4. pad the number with extra bits

If we are asked to convert the denary number 39.75 into binary floating point we first need to find out

the binary equivalent:

128 64 32 16

0

1 .

1 . 1

How far do we need to move the binary point to the left so that the number is normlised?

0

0 . 1

So to get our decimal point back to where it started, we need to move 6 places to the right. 6 now

becomes your exponent.

0.100111110 | 000110

If you want to check your answer, convert the number above into decimal. You get 39.75!

EXAMPLE 1

Work out the binary floating point for the following, using 10 bits for the mantissa and 6 bits for the

exponent:

67

COMPUTERSCIENCE/UPPER6/P3

Page 12

Answer:

128 64 32 16

0

1 .

1 . 0

How far do we need to move the binary point to the left so that the number is normlised?

0 . 1

To get the front to be normalised we must move the decimal point 7 places. (moving it 6 places would

have made the number negative!)

0.100001100 | 000111

EXAMPLE2

23.25

[Collapse]

Answer:

128 64 32 16

0

1 .

1 . 0

How far do we need to move the binary point to the left so that the number is normlised?

0

0 . 1

To get the front to be normalised we must move the decimal point 5 places. (moving it 4 places would

have made the number negative!)

0.101110100 | 000101

EXAMPLE 3

123.80

[Collapse]

Answer :

COMPUTERSCIENCE/UPPER6/P3

Page 13

128 64 32 16

0

1 .

1 . 1

How far do we need to move the binary point to the left so that the number is normlised?

0 . 1

To get the front to be normalised we must move the decimal point 7 places.

0.1111011111 | 000111

But this is using 11 bits for the mantissa, we have to drop one, losing accuracy!

0.111101111 | 000111

EXAMPLE4

-513

[Collapse]

Answer :

1024 512 256 128 64 32 16

0

1 .

1 . 0

Convert this into its negative form using the flipping rule:

1024 512 256 128 64 32 16

1

1 .

1 . 0

How far do we need to move the binary point to the left so that the number is normalized?

1 . 0

To get the front to be normalized we must move the decimal point 10 places.

1.011111111 | 001010

COMPUTERSCIENCE/UPPER6/P3

Page 14

Notice that we have had to drop the last one as this would not have fitted into 10 bits for the mantissa.

This means that the number shown is only:

10111111110.0

converting this into denary:

01000000010.0 = -514

You'll look at errors using floating point numbers very soon

For when you have a 16bit number where the mantissa is 10bits and the exponent is 6 bits:

the largest positive number will be:

Mantissa: 0.111111111

Exponent: 011111

the smallest positive number will be:

Mantissa: 0.000000001

Exponent: 100000

the largest negative number will be:

Mantissa: 1.000000000

Exponent: 011111

Mantissa: 1.111111111

Exponent: 100000

COMPUTERSCIENCE/UPPER6/P3

Page 15

When storing numbers we need to use the space we are given in the most efficient way. We need

the most efficient representation we can. With a fixed number of bits, a normalized representation of

a number will display the number to the greatest accuracy possible. In summary normalized

numbers:

Save space

As a rule of thumb: when dealing with Floating point numbers in binary you must make sure that the

first two bits are different. That is:

1.1

0.0

COMPUTERSCIENCE/UPPER6/P3

Page 16

for it be normalised. To

do this we need to move the decimal place one position to the right, and to retain the same number

represented by the unnormalised number we need to change the exponent accordingly. With a

movement one place right to normalise the number we need to change the exponent to move the

decimal point one place left to compensate. Thus subtracting one from the current exponent:

To get the mantissa normalised we need to move the decimal point two places to the right. To

maintain the same value as the original floating point number we need to adjust the exponent to be

two smaller.

Now check that the new normalised value has the same value as the original.

NOTE: Make sure that normalising a number does not change the sign bit. e.g.

1. Normalise the left hand side (mantissa).

2. Record the number of bounces it has taken to normalise

COMPUTERSCIENCE/UPPER6/P3

Page 17

3. Work out the exponent of the normalised number by using: original exponent

bounce

Make sure that your normalisation does not change the sign of the mantissa

Normalisation makes sure there is only one representation for each number

Are the Following numbers normalised?

EXAMPLE1

0.010000000 111111

Answer: No, as it starts with 0.0

EXAMPLE2

0.111111000 111111

Answer: Yes, as it starts with 0.1

EXAMPLE3

1.100000010 111111

Answer: No, as it starts with 1.1

COMPUTERSCIENCE/UPPER6/P3

Page 18

EXAMPLE1

0 010000000 111111

Answer:

1. 0.010000000 111111 -> 00.10000000 111111

2. One place to the right

3. 111111 - 1 = -1 -1 = -2 = 000010 (+2) = 111110 (-2)

00.10000000 111110 = 0.100000000 111110

EXAMPLE2

0 001101000 000110

Answer :

1. 0.001101000 000110 -> 000.1101000 000110

2. Two places to the right

3. 000110 - 2 = 6 - 2 = 4 = 000100 (+4)

000.1101000 000100 = 0.110100000 000100

COMPUTERSCIENCE/UPPER6/P3

Page 19

EXAMPLE3

1 111111010 000011

Answer :

1. 1.111111010 000011 -> 1111111.010 000011

2. Six places to the right

3. 000011 - 6 = 3 - 6 = -3 = 111101 (-3)

111111.010 111101 = 1.01000000 111101

COMPUTERSCIENCE/UPPER6/P3

Page 20

(effects of changing allocation of bits to mantissa

and exponent)

Precision

When using floating point numbers you have to balance the range and the precision of numbers.

That is whether you want to have a very large range of values or you want a number that is very

precise down to a large number of decimal places. This means that you are going to always weigh

up how many digits should be used for the mantissa and how many should be used for the

exponent. In summary:

If you want a very precise number use more digits for the mantissa and less for the exponent

as this will allow for more decimal places

If you want a large range of numbers use more digits for the exponent and less for the

mantissa.

COMPUTERSCIENCE/UPPER6/P3

Page 21

OVERFLOW

When the result of a sum is too large to be represented by your number system you might run out of

space to represent it and end up storing a much smaller number

Try and show 99,999,999,999,999,999,999 in 12 bit FP

UNDERFLOW

COMPUTERSCIENCE/UPPER6/P3

Page 22

When a number or the result of an equation is too small, you might not have enough digits in your

mantissa and exponent to show it. In the following example the number would register as 0

Try and show 0.0000000000000000000000000001 in 12 bit FP

TRUNCATION

Why computers cannot represent real numbers : 2, , but only

approximation?

truncation will occur.

COMPUTERSCIENCE/UPPER6/P3

Page 23

When we try to represent some numbers sometimes we can't within the space we have been given,

for example trying to write down 1/3 = 0.33333333; you see what I mean? With floating point

numbers you can't always get perfect precision and sometimes we suffer errors.

Feed this equation into google:

999999999999999 - 999999999999998

The browser will perform a floating point calculation and give you the answer of 0!

So recognizing that we can have rounding errors with floating point numbers we'll take a look at the

different errors that might be caused. The following number wants to be represented in binary 23.27,

the closest we get is 23.25

COMPUTERSCIENCE/UPPER6/P3

Page 24

- BM Assignment SolutionsUploaded byMir Mazar
- 1.8.2 Relational Database ModelingUploaded bysniper
- 1.4.4 Assembly LanguageUploaded byAbbas Haider
- User-Defined Data TypeUploaded byEdgardo Leysa
- Olevel Computer Science Notes (2210)Uploaded byKhawaja Shoaib
- Python3 GuideUploaded byPK
- 1.4.2 the Fetch-execute CycleUploaded byAbbas Haider
- Revision Notes Paper 3Uploaded byVishal Paupiah
- Lin Segel applied mathematicsUploaded byLei Huang
- Computer science 9608Uploaded byKrishna Seewooruttun
- User-Defined Data TypesUploaded byBaba Jayden
- Computer Science 2210 XI Worksheet -Mock 2015.pdfUploaded bysofia_baloch09
- Multivariable Chapter7Uploaded bygopalchandramahato
- Notes Logic GateUploaded byVishal Paupiah
- 9691-01 Revision Notes (Modified F451)Uploaded byChew Shu Ren
- 1.3.3 Logic Gates and Logic CircuitsUploaded byTrynos
- IGCSE Computer Science 0478 Notes 1.1.1 - 1.1.4Uploaded byMarwan Yasser
- Multiplying Floating Point NumbersUploaded byMikaelYuruBeli
- o Level Computer ScienceUploaded byTrynos
- A2 computer Science - Computer Networking ProblemsUploaded byEdgardo Leysa
- QuestionsUploaded byAnurag Yadav
- Simulation of Marine Controlled Source Electromagnetic Measurements Using a Parallel Fourier Hp-Finite Element MethodUploaded byOkto Ivansyah
- Digital signal ProcessingUploaded byEngr. Abdullah
- 05 V60 COS AttributesUploaded bysorinbut
- Chapter 2 ArithmeticUploaded bynajakz
- Homework 2 Design Patterns v 3Uploaded byDiana Hermith
- EEE-228-Lec2.pdf.2012_02_21_Ogretim_2Uploaded byselamicelik65
- Chapter OneUploaded by_84mhm
- 08_CoprocessorsUploaded byRameez Raja Chowdhary
- Solutions Chapter 5Uploaded byAbdu Abdoulaye

- Final SolutionsUploaded byshera48
- Free Guide SSC CGL Tier 1 Solved PapersUploaded byShaik Baji
- NetBackup OperGuide VaultUploaded byRajesh Kanna
- Gross National HappinessUploaded byrajeshsapkota123
- Auto LevelerUploaded byvisaguy
- Manuscript a.sahooUploaded bysujayan2005
- Jarvis, W. Todd - In search of a New Identity, Good Water NeighborsUploaded byolivetalk
- ct13-ct15-engine-spec-sheetUploaded byapi-277145483
- 373_810T 820T GA3 Programming.pdfUploaded byKosta Maksin
- AutoIt QuickrefUploaded byLuis Ernesto Marin Bustillo
- RevisionUploaded byJaimeHernándezLópez
- D71 - High speed communication networksUploaded byvasukaruppiah
- A Case Study of Assessment on ReposiUploaded byVaskar Jung Karki
- ibuprofenUploaded byramsrivatsan
- Class 7 Holidays Homework AssignmentUploaded bydeep_72
- ROW15-proceedings.pdfUploaded bymikaelcollan
- PDF Oil SkimmerUploaded byarjmandquest
- Section 11 - Prefabricated GirdersUploaded byfivehours5
- Liquid Soap CompositionUploaded byJavier Becerra
- Chap.5 Eigenvalues EigenvectorsUploaded byndarubagus
- VKV Jairampur under Top 30 InnovationsUploaded byVivekananda Kendra Vidyalaya Arunachal Pradesh Trust
- Goa Growth GuideUploaded bysatyatiwary
- BeamUploaded byكرم عمرو
- (Methods in Molecular Biology 1299) Gary R. Skuse, Maureen C. Ferran (Eds.)-Cardiomyocytes_ Methods and Protocols-Humana Press (2015)Uploaded byzaazlx
- Awards of Excellence in Housing finalistsUploaded byedmontonjournal
- Tomb Tapper - James BlishUploaded bySachinAPatil
- Harsha Enterprise(Foundry industry )Uploaded bySarika Chougule
- E1 Characteristic Curve of the Fuel CellUploaded bylianghong.koh5914
- CuriosityUploaded bypolyphonic553
- assignment 3 - artifact historyUploaded byapi-413238764