IEEE 754 floating-point exercises — laps, gaps to the record and an old 16-bit stopwatch (and the 3.25 that turned into 2.0000012)
Revising for the midterm with a classmate, we set each other challenges: one said a number and the other converted it to IEEE 754 as fast as possible. I got 3.25. Binary 11.01, normalised 1.101 · 2¹, exponent 128 = 10000000, mantissa 101. I wrote the 32 bits, turned them into hexadecimal (40000005) and, proudly, typed them into a converter to check: 2.0000012. I had put the three mantissa bits pushed to the right, as if it were an integer, instead of right after the point. One placement mistake and 3.25 became almost 2.
These exercises are designed so that those mistakes happen to you here and not in the exam. There are three levels, from the most direct one to the club’s old stopwatch with a format that is not the standard one, a «What’s wrong here?» section with other people’s solutions hiding a mistake, the step-by-step solutions, a practice quiz and the cheat sheet. If you get stuck, the guided practice solves problems just like these with every step and the theory explains it from scratch.
Table of Contents
How to use this article
- Do each level on paper before opening its solution, as in the exam: binary, normalise, fields and hexadecimal, written down.
- Compare with the expected result under each statement. If it does not match, look for the mistake before reading the solution.
- In «What’s wrong here?», predict what is wrong before reading the explanation.
- Finish with the quiz, which marks itself and does not count for anything: repeat it until you get it all right.
Level 1: the basics
Statement. The race stopwatch stores in IEEE 754 single precision:
a) A runner’s warm-up lap: 12.5 s. Give it in hexadecimal.
b) The reaction time at the start: 0.75 s. Give it in hexadecimal.
c) One of the stored readings is C0300000. What number is it?
Expected result: a) 41480000; b) 3F400000; c) −2.75.
In b) the number is less than 1: the real exponent is negative. In c), the leading C already tells you the sign: 1100, it starts with 1.
Level 2: negatives, small numbers and precision
Statement.
a) A runner has improved their time by 27.5625 s and the stopwatch stores the gap as −27.5625. Give it in hexadecimal.
b) What number is the reading 3E200000?
c) The stopwatch is about to store 0.2 s and 0.625 s. Is either of them stored exactly? Give the hexadecimal of each.
d) How many single-precision numbers are there strictly between 8 and 9 (counting neither 8 nor 9)?
Expected result: a) C1DC8000; b) 0.15625; c) 0.2 is not exact (3E4CCCCD), 0.625 is (3F200000); d) .
In c), do the table of multiplications by 2 and see whether it reaches 0. In d), think about which exponent the numbers between 8 and 9 have and how many mantissa bits are left for the fractional part.
Level 3 (challenge): the club’s old stopwatch
The club has an old stopwatch that stores times in 16 bits with its own format, which is not IEEE 754:
- 1 sign bit (0 positive, 1 negative), on the left.
- 5 exponent bits in excess 16 (), with no reserved values.
- 10 bits of fractional mantissa, normalised: the point goes to the left of the first 1,
Statement.
a) Work out the largest positive number and the smallest positive number it can store, without a hidden bit and with a hidden bit (in that case, the 1 of is not stored).
b) Represent the 83.375 s lap without and with a hidden bit, in hexadecimal.
c) Represent the −0.15625 s gap in both ways.
Expected result: a) largest: 32736 without a hidden bit and 32752 with one; smallest positive: in both cases; b) 5E9B and 5D36; c) BA80 and B900.
With 5 bits in excess 16 the exponents go from −16 (00000) to +15 (11111). The largest mantissa without a hidden bit is 0.1111111111; with a hidden bit eleven ones fit after the point, because the first one is not stored.
What’s wrong here?
Three classmates have handed in their solutions. All three have a mistake. Before reading the explanation, try to find it.
Fragment 1: 21.25
21.25 = 10101.01 = 1.010101 · 2^4 sign 0 · exponent 4 = 00000100 · mantissa 010101 0 | 00000100 | 01010100000000000000000 = 022A0000
Can you see it? The exponent has been stored as plain 4. The excess is missing: . With 00000100 the real exponent would be , and 022A0000 is about : a 21-second lap turned into almost nothing.
Thinking «the exponent is 4» and storing it as it is. The exponent field never stores the real exponent: it stores the real one + 127.
The right solution: 0 | 10000011 | 010101000… = 41AA0000.
A «normal» exam number (between 1 and a few thousand) always starts with 3, 4, B or C in hexadecimal. A 0 or an 8 in front of a number like that is a sign of an exponent without the excess.
Fragment 2: 10.625
10.625 = 1010.101 = 1.010101 · 2^3 sign 0 · exponent 3 + 127 = 130 = 10000010 · mantissa 1010101 0 | 10000010 | 10101010000000000000000 = 41550000
Here the exponent is fine, but the hidden 1 has slipped into the mantissa: 1010101 instead of 010101. With the formula, 41550000 reads as , not 10.625.
Copying every digit of the normalised form into the mantissa. The 1 before the point is never stored in IEEE 754.
The right solution: 0 | 10000010 | 0101010000… = 412A0000.
Fragment 3: 3.25
3.25 = 11.01 = 1.101 · 2^1 sign 0 · exponent 1 + 127 = 128 = 10000000 · mantissa 101 0 | 10000000 | 00000000000000000000101 = 40000005
This is my midterm mistake. The mantissa 101 has been padded with zeros on the left, as if it were a 23-bit integer. But the mantissa is the digits after the point, in order: 1.101 is 1.10100000…, so the zeros go after it.
Aligning the mantissa to the right. The padding zeros go on the right, as in 0.5 = 0.500.
Look at the last hexadecimal digits: in an «exam» number, with few mantissa bits, the last digits are 0. A 5 at the end of such a simple number is suspicious.
The right solution: 0 | 10000000 | 1010000… = 40500000.
Solutions
Level 1
a) 12.5. and , so (the point jumps 3 places left). Sign 0; exponent ; mantissa 1001 and zeros.
0 | 10000010 | 10010000000000000000000 0100 0001 0100 1000 0000 0000 0000 0000 = 41480000
Why split the number in two: the integer part is converted by dividing by 2 and the fractional part by multiplying by 2. Then you join 1100 and .1 and all that is left is moving the point.
The step people skip most is the last one: the groups of 4 for the hexadecimal are made over the 32 bits in a row, without looking at where each field ends.
| Group | Bits | What it holds | Hex |
|---|---|---|---|
| 1st | 0100 | sign 0 and exponent 100 | 4 |
| 2nd | 0001 | exponent 0001 | 1 |
| 3rd | 0100 | exponent 0 and mantissa 100 | 4 |
| 4th | 1000 | mantissa 1 and three zeros | 8 |
| 5th to 8th | 0000 | padding zeros | 0 |
Converting each field to hexadecimal separately (the exponent 10000010 as 82) and writing the pieces one after another. You don’t get 41480000: the sign takes 1 bit and the exponent 8, not whole hexadecimal digits.
b) 0.75. (one jump to the right). Sign 0; exponent ; mantissa 1 and zeros.
0 | 01111110 | 10000000000000000000000 0011 1111 0100 0000 0000 0000 0000 0000 = 3F400000
Look at the first digit: 3, because the stored exponent starts with 0 (number less than 1).
There is no need for the multiply-by-2 table here: 0.75 is 0.5 + 0.25, two powers of 2 you can spot by eye. What you have to think about before the arithmetic is which way the point goes: the first 1 is to its right, the point moves right and the exponent comes out negative. A number less than 1 always stores an exponent below 127.
Writing exponent +1 because «the point has moved one place». You store 128 and get 40400000, which is 3: four times 0.75.
c) C0300000. In binary, 1100 0000 0011 0000…:
- Sign 1: negative.
- Exponent 10000000 = 128 → .
- Mantissa 011 → 1.011.
- Value: .
Reading goes the opposite way to writing: first the bits, then you cut them into fields. The first three digits are enough, because the rest are zeros: C, 0 and 3 are 1100 0000 0011, and the cut falls like this: 1 | 10000000 | 011.
Forgetting the hidden 1 when reading. With 0.011 instead of 1.011, exponent 1 gives 0.11 in binary, which is 0.75, and you get −0.75 instead of −2.75.
Level 2
a) −27.5625. ; . So . Sign 1; exponent ; mantissa 10111001.
1 | 10000011 | 10111001000000000000000 1100 0001 1101 1100 1000 0000 0000 0000 = C1DC8000
The sign changes nothing else: you work out 27.5625 as if it were positive and put a 1 in front at the end. That is why C1DC8000 and the positive one, 41DC8000, only differ in the first digit (C = 1100, 4 = 0100).
Taking the two’s complement of 41DC8000, as with integers. You get BE238000, which the stopwatch would read as roughly −0.1597. In IEEE 754 the sign is a separate bit; there is no complement.
b) 3E200000. 0011 1110 0010 0000…: sign 0; exponent 01111100 = 124 → −3; mantissa 01 → 1.01. Value: . It is the gap to the record from the theory, now positive: only the first digit changes, from B to 3.
The stored exponent, 124, is below 127: the number is less than 1 before doing any arithmetic. With exponent −3, the point in 1.01 moves three places left and two zeros appear on the way: 1.01 → 0.101 → 0.0101 → 0.00101.
Moving the point to the right with a negative exponent. You get 1010 = 10, which would be 41200000.
c) 0.2 and 0.625. The table for 0.2 gives 0, 0, 1, 1, 0, 0, 1, 1… and 0.2 comes back: it is recurring, , so it is not exact. Normalised, : the same mantissa as 0.1 (doubling a number only changes the exponent) and the same rounding up. Exponent :
0 | 01111100 | 10011001100110011001101 = 3E4CCCCD
The table for 0.2, step by step:
| Step | Calculation | Bit | Left |
|---|---|---|---|
| 1 | 0.2 · 2 = 0.4 | 0 | 0.4 |
| 2 | 0.4 · 2 = 0.8 | 0 | 0.8 |
| 3 | 0.8 · 2 = 1.6 | 1 | 0.6 |
| 4 | 0.6 · 2 = 1.2 | 1 | 0.2 |
| 5 | 0.2 comes back | — | 0011 repeats |
The final 1 in CCCD is the rounding: the mantissa is cut at 23 bits, which end in …1001100, and the bit that would come next is a 1, so it rounds up: …1001101.
Cutting without rounding and giving 3E4CCCCC. It is 0.19999998…, further from 0.2 than 3E4CCCCD (0.20000000298…).
The table for 0.625 gives 1 (1.25), 0 (0.5), 1 (1.0) and stops: , exact. Normalised, ; exponent 126:
0 | 01111110 | 01000000000000000000000 = 3F200000
The underlying reason: is a sum of powers of 2; 0.2 is not.
d) Between 8 and 9. Every number in has exponent 3: . Between 8 and 9 the integer part is 1000, so the first 3 mantissa bits are fixed at 000 (8 = 1.000 · 2³) and the remaining 20 can be anything: numbers from 8 (included) to 9 (not included). Taking away 8, are left. The gap between them is , a bit less than a millionth.
The approach before counting: if all the numbers between 8 and 9 share an exponent, counting them means counting how many mantissas fit with the bits that are left free.
| Number | Binary | Normalised | Mantissa |
|---|---|---|---|
| 8 | 1000 | 1.000 · 2³ | 000 and twenty zeros |
| 9 | 1001 | 1.001 · 2³ | 001 and twenty zeros |
| in between | 1000.… | 1.000… · 2³ | 000 and 20 free bits |
Counting all the numbers with exponent 3, , more than eight million. Those are the ones between 8 and 16.
Level 3
a) Range. The exponents go from to .
- Without a hidden bit: the largest mantissa is and the smallest . Largest number: . Smallest positive: .
- With a hidden bit: the 1 of is not stored and 10 more bits fit after it: the largest mantissa is . Largest number: . The smallest positive does not change: .
The hidden bit does not widen the range of exponents: it gains precision (one more mantissa bit), which is why the maximum gets a little closer to .
The approach: the largest number puts the largest exponent together with the largest mantissa, and the smallest positive one, the smallest exponent with the smallest mantissa. The smallest mantissa is not 0.0000000000: it is normalised and always starts with 0.1.
| Case | Sign | Exponent | Stored mantissa | Hex |
|---|---|---|---|---|
| Largest, with or without hidden bit | 0 | 11111 | 1111111111 | 7FFF |
| Smallest positive, without hidden bit | 0 | 00000 | 1000000000 | 0200 |
| Smallest positive, with hidden bit | 0 | 00000 | 0000000000 | 0000 |
The same bits are worth different amounts depending on whether you read them with the hidden 1 or without it. That is why the largest changes and the smallest does not: in both cases it is .
b) 83.375. : with a fractional mantissa, the point goes to the left of the first 1, so it jumps 7 places (not 6, as in IEEE 754). Exponent .
First the number in binary, in parts, as in level 1: 83 = 64 + 16 + 2 + 1 = 1010011 and 0.375 = 0.25 + 0.125 = 0.011. Then the normalisation of this format: the point goes just before the first 1, one place further left than in IEEE 754, and the exponent comes out one higher.
Normalising out of habit as in IEEE 754, , and storing 6 + 16 = 22. Without a hidden bit you get 5A9B, which this format reads as 41.6875: half the lap.
- Without a hidden bit, the mantissa is the 10 bits 1010011011 (they fit exactly):
0 | 10111 | 1010011011 0101 1110 1001 1011 = 5E9B
- With a hidden bit, the first 1 is skipped and the next 10 are stored: 010011011 and a padding 0, 0100110110:
0 | 10111 | 0100110110 0101 1101 0011 0110 = 5D36
c) −0.15625. (the point jumps 2 places right to sit in front of the first 1). Exponent ; sign 1.
- Without a hidden bit: mantissa 1010000000 → 1 | 01110 | 1010000000 = 1011 1010 1000 0000 = BA80.
- With a hidden bit: mantissa 0100000000 → 1 | 01110 | 0100000000 = 1011 1001 0000 0000 = B900.
This number already came up in level 2, with in IEEE 754. Here the exponent is −2 for the same reason as in b): the point stays in front of the first 1, not behind it. With a hidden bit, the 1 of 0.101 is not stored: 01 is left and it is padded with zeros on the right, 0100000000.
Copying the exponent −3 from level 2. You store 13 = 01101 and, without a hidden bit, get B680, which in this format is −0.078125: half again.
In a format like this there is no way to write 0 (the mantissa always starts with 0.1) unless the statement reserves a code for it. IEEE 754 solves it with its special cases.
Practice quiz
Twenty questions to review the whole topic. They do not count for anything and you can repeat them as many times as you like; each one has its explanation. In the boxes, write hexadecimal in upper or lower case and binary numbers without spaces.
How many bits does each field of an IEEE 754 single-precision number have (sign, exponent and mantissa)?
- 1, 8 and 23
- 1, 11 and 52
- 1, 7 and 24
- 1, 8 and 24
Solution
Answer: 1, 8 and 23
Single precision splits its 32 bits into 1 sign bit (bit 31), 8 exponent bits (bits 30 to 23) and 23 mantissa bits (bits 22 to 0).
The real exponent of a number is . Which 8 bits are stored in the exponent field? Write them without spaces.
Solution
Answer: 10000101
In excess 127 we store .
Fill in the stored exponent (in decimal) for each real exponent, in excess 127.
| Real exponent | Stored exponent |
|---|---|
| 6 | |
| -3 | |
| 0 | |
| -126 |
Solution
| Real exponent | Stored exponent |
|---|---|
| 6 | 133 |
| -3 | 124 |
| 0 | 127 |
| -126 | 1 |
Add 127: , , and , the smallest exponent of a normal number.
Write the fractional part in binary (with the point, for example 0.1).
Solution
Answer: 0.011
(0), (1), (1): . Check: .
Give in hexadecimal (8 digits) the number in IEEE 754 single precision.
Solution
Answer: C0D00000
. Sign 1, exponent , mantissa 101: 1 | 10000001 | 101000… = 1100 0000 1101 0000… = C0D00000.
Which decimal number does the word 41100000 represent?
Solution
Answer: 9
0100 0001 0001 0000…: sign 0, exponent 10000010 = 130 → 3, mantissa 001 → 1.001. .
Say whether each statement about IEEE 754 is true or false.
- The 1 left before the point after normalising is not stored in the mantissa.
- The IEEE 754 exponent is stored in two’s complement.
- Changing the sign of a number only changes bit 31.
- Every number with two decimal places fits exactly in single precision.
- The stored exponents 00000000 and 11111111 are reserved for special cases.
Solution
- T — The 1 left before the point after normalising is not stored in the mantissa.
- F — The IEEE 754 exponent is stored in two’s complement.
- T — Changing the sign of a number only changes bit 31.
- F — Every number with two decimal places fits exactly in single precision.
- T — The stored exponents 00000000 and 11111111 are reserved for special cases.
The 1 is hidden; the exponent goes in excess 127, not two’s complement; the sign is a separate bit (sign-magnitude); 0.1 or 0.25 + 0.01 are not exact (only sums of powers of 2 are); and the exponents at the ends are reserved for zero, denormals, infinity and NaN.
Match each 32-bit word with what it represents.
| 00000000 | |
| 7F800000 | |
| 7FC00000 | |
| 00800000 | |
| 3F800000 |
Definitions:
- the smallest normal
- positive zero
- the largest number
- one
- plus infinity
- NaN
Solution
- 00000000 → positive zero
- 7F800000 → plus infinity
- 7FC00000 → NaN
- 00800000 → the smallest normal
- 3F800000 → one
All zeros is +0; exponent 11111111 with mantissa 0 is infinity and with a non-zero mantissa, NaN; 00800000 has exponent 00000001 and mantissa 0: ; 3F800000 has exponent 127 (real 0) and mantissa 0: 1. The largest number would be 7F7FFFFF.
Put in order the steps to convert a decimal into IEEE 754 single precision in hexadecimal.
- Write the sign, the exponent e + 127 and the mantissa without the 1
- Convert the absolute value to binary (integer part by divisions, fractional part by multiplications)
- Normalise to 1.mantissa times 2 to the e
- Write one hexadecimal digit per group
- Join the 32 bits and group them in fours
Solution
Correct order:
- Convert the absolute value to binary (integer part by divisions, fractional part by multiplications)
- Normalise to 1.mantissa times 2 to the e
- Write the sign, the exponent e + 127 and the mantissa without the 1
- Join the 32 bits and group them in fours
- Write one hexadecimal digit per group
It is the four-step method of the theory: binary, normalise, fields and hexadecimal (the last one in two stages: group and translate).
What is the stored mantissa of ?
- 010011011 followed by zeros
- 1010011011 followed by zeros
- 011 followed by zeros
- zeros followed by 010011011
Solution
Answer: 010011011 followed by zeros
: the mantissa is the digits after the point, 010011011, with zeros on the right up to 23 bits.
Complete the sentence about normalising 0.00101.
To normalise 0.00101 the point moves ____ places to the ____, so the real exponent is ____ and the stored exponent starts with ____.
Words:
- 3
- 2
- right
- negative
- positive
- 1
- left
- 0
Solution
To normalise 0.00101 the point moves 3 places to the right, so the real exponent is negative and the stored exponent starts with 0.
: three jumps to the right, exponent −3 and stored , which starts with 0.
Which of these decimals are stored exactly in IEEE 754 single precision?
- 0.625
- 0.1
- 83.375
- 0.2
- 0.15625
Solution
Answer: 0.625 · 83.375 · 0.15625
A decimal is exact in binary if its fractional part is a sum of powers of 2 (and the bits fit). 0.1 and 0.2 are not and are rounded to the nearest float.
When reading the word 00200000, what do you have to do?
- Treat it as a denormal: 0.mantissa times 2 to the −126
- Apply the normal formula with exponent −127
- It is zero
- It is NaN
Solution
Answer: Treat it as a denormal: 0.mantissa times 2 to the −126
00200000 has sign 0, exponent 00000000 and mantissa 01000…: denormal, .
Fill in the three fields of (exponent and mantissa in binary, without spaces; of the mantissa, only its first 8 bits).
| Sign | Exponent | Mantissa (first 8 bits) |
|---|---|---|
Solution
| Sign | Exponent | Mantissa (first 8 bits) |
|---|---|---|
| 1 | 10000011 | 10111001 |
Sign 1 (negative); exponent ; mantissa 10111001 followed by zeros. In hexadecimal, C1DC8000.
Give in hexadecimal (8 digits) the number in IEEE 754 single precision.
Solution
Answer: 42C80000
. Sign 0, exponent 133 = 10000101, mantissa 1001: 0 | 10000101 | 1001000… = 0100 0010 1100 1000… = 42C80000.
What is the advantage of storing the exponent in excess instead of two’s complement?
- The order of the codes is the order of the exponents, and they are compared as unsigned numbers
- It allows larger exponents
- It avoids overflow
- It saves a bit
Solution
Answer: The order of the codes is the order of the exponents, and they are compared as unsigned numbers
In excess 127, 00000000 is the smallest exponent and 11111111 the largest: comparing exponents is comparing unsigned integers.
The stopwatch stores a tenth of a second, 0.1, in single precision. Which hexadecimal does it store?
Solution
Answer: 3DCCCCCD
; exponent 123 = 01111011; the mantissa is cut at 23 bits and, since the leftover starts with 11, it is rounded up: …1101. Result 3DCCCCCD, slightly more than 0.1.
Which decimal number does the word C1A00000 represent?
Solution
Answer: -20
1100 0001 1010 0000…: sign 1, exponent 10000011 = 131 → 4, mantissa 01 → 1.01. .
How many single-precision numbers are there strictly between 8 and 9?
- Infinitely many
Solution
Answer:
The numbers in are ; between 8 and 9 the first 3 mantissa bits are 000 and the other 20 are free: numbers from 8 included, without it.
True or false: double precision, format changes and results that are too big.
- Double precision uses 11 exponent bits in excess 1023.
- Converting 0.1 from double to single precision loses nothing.
- 17.25 can be converted from double to single precision without losing anything.
- In IEEE 754 a result that is too big wraps around and comes out negative, as in two’s complement.
Solution
- T — Double precision uses 11 exponent bits in excess 1023.
- F — Converting 0.1 from double to single precision loses nothing.
- T — 17.25 can be converted from double to single precision without losing anything.
- F — In IEEE 754 a result that is too big wraps around and comes out negative, as in two’s complement.
Double has 1 + 11 + 52 bits and excess . 0.1 is not exact and is rounded again when going down to 24 significant bits; 17.25 = 10001.01 fits in both. A result that is too big in floating point becomes infinity; it does not wrap around.
What next?
With this you have numbers with a point: how they are stored, how they are read and why some do not fit exactly. If you come from two’s complement, you have already seen the three ways of storing signed integers (sign-magnitude, ones’ complement and two’s complement) and now a fourth one, excess, inside the exponent.
In the practical part of IC1 you work with integers in the registers, but the topic helps you understand what you see in QtSpim: if you write .float 83.375 in the data segment, 42a6c000 appears in the Data tab, and QtSpim has system calls to print and read floats next to the integer and string ones you saw in System calls in MIPS. And when you want to test yourself with assembly, the IC1 practical mock exam has the structure of the real exam.
The next paper topic is Codes: BCD, Gray and ASCII/Unicode, other ways of storing information in binary that are not numbers to operate on.
To check your solutions, type the number or the word into the IEEE 754 explorer simulator; it also has the old 16-bit format from level 3, with and without a hidden bit, and its «Test yourself» section brings new numbers.
Cheat sheet: IEEE 754 floating point
The essentials in 30 seconds
- Single precision: 1 + 8 + 23 = 32 bits; double: 1 + 11 + 52 = 64.
- Normal value: .
- Storing: binary → normalise → sign, , mantissa without the 1 (zeros on the right) → hexadecimal in fours.
- Reading: hexadecimal → binary → look at the exponent (special?) → and the 1 in front.
- Stored exponent: starts with 1 if the number is ≥ 2, 01111111 if it is between 1 and 2, starts with 0 if it is < 1.
I want to…
| I want to… | How | Result |
|---|---|---|
| convert 0.375 to binary | multiply by 2: 0.75 → 0; 1.5 → 1; 1.0 → 1 | 0.011 |
| normalise 1010011.011 | point 6 places to the left | |
| store exponent 6 | 10000101 | |
| store exponent −3 | 01111100 | |
| convert 83.375 to IEEE 754 | 0 | 10000101 | 0100110110… | 42A6C000 |
| read BE200000 | 1 | 01111100 | 01… → | −0.15625 |
| know if a decimal is exact | does the ×2 table reach 0? | 0.625 yes; 0.1 and 0.2 no |
| round a recurring number | look at the first leftover bit (and the next ones) | 0.1 → 3DCCCCCD |
| change the sign | flip bit 31 | 3… ↔ B…, 4… ↔ C… |
Values worth knowing
| Hexadecimal | Value |
|---|---|
| 00000000 / 80000000 | +0 / −0 |
| 3F800000 | 1 |
| 3F000000 | 0.5 |
| 40000000 | 2 |
| 7F800000 / FF800000 | +∞ / −∞ |
| 7FC00000 | NaN |
| 00800000 | , the smallest normal |
| 7F7FFFFF | about , the largest |
Templates from the exercises
12.5 = 1100.1 = 1.1001 · 2^3 → 0 | 10000010 | 1001… = 41480000 0.75 = 0.11 = 1.1 · 2^-1 → 0 | 01111110 | 1000… = 3F400000 -27.5625 = -11011.1001 = -1.10111001 · 2^4 → 1 | 10000011 | 10111001… = C1DC8000 0.625 = 0.101 = 1.01 · 2^-1 → 0 | 01111110 | 01000… = 3F200000
Symptom and likely cause
| Symptom | Likely cause |
|---|---|
| The hexadecimal of a normal number starts with 0 or 8 | you did not add 127 to the exponent |
| Reading your result gives a noticeably bigger number | the hidden 1 is inside the mantissa |
| The last hexadecimal digits are not 0 for a simple number | the mantissa is pushed to the right |
| A number less than 1 has a stored exponent starting with 1 | you counted the jumps of the point backwards |
| You get 7 or 9 hexadecimal digits | a bit is missing or extra (count 1 + 8 + 23) |
| When reading, an absurd number comes out with exponent 00000000 or 11111111 | it was a special case |
Before handing in, ask yourself
- Have I added (or subtracted) 127 to the exponent?
- Have I left the hidden 1 out of the mantissa and padded with zeros on the right?
- Do I have 32 bits and 8 hexadecimal digits?
- Have I done the way back and do I get the number in the statement?
Did this article help you? Here is how you can support SergioLearns →
Ready for the exam?IC1 practical mock exam — MIPS in QtSpim with other data, subroutines and keyboard input (and why part 1 decides almost everything)


