The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+28 votes

The following is a scheme for floating point number representation using 16 bits.

Bit Position 15 14 .... 9 8 ...... 0
  s e m
  Sign Exponent Mantissa

Let s, e, and m be the numbers represented in binary in the sign, exponent, and mantissa fields respectively. Then the floating point number represented is:

$$\begin{cases}(-1)^s \left(1+m \times 2^{-9}\right) 2^{e-31}, & \text{ if the exponent } \neq 111111 \\  0, & \text{ otherwise} \end{cases}$$

What is the maximum difference between two successive real numbers representable in this system?

  1. $2^{-40}$
  2. $2^{-9}$
  3. $2^{22}$
  4. $2^{31}$
asked in Digital Logic by Veteran (59.5k points) | 3.4k views

First of all this is one of the best question.

Let us do our analysis in decimal system -

Let we us have 1-Digit Mantissa and 2-Digit Exponent then Mantissa range $-9$ to $9$, and 2-Digit Exponent range $0$ to $100$.

Now possible numbers are $-900, -800 ...... -1, 0, 1, 2 ....10, 20, 30,...800, 900 $

It could be observed clearly that max difference between two consecutive number will be max(100) when exponent value is max. Similarly min difference between two consecutive number will be minimum(1) when exponent value is least.

Same principle could be used in the mentioned question.

ping @Puja Mishra, @Shivam Chauhan, @Manu Thakur, @Anu007,  @Hemant Parihar, @ sushmita,  @VS  @Shweta Nair @Krish__,  @Ashwin Kulkarni @reena_kandari  and @srestha ji.

5 Answers

+31 votes
Best answer
Maximum difference between two successive real number will occur at extremes. This is because numbers are represented upto mantissa bits and as the exponent grows larger, the difference gets multiplied by a larger value. (The minimum difference happens for the least positive exponent value).
Biasing will be done by adding 31 as given in question. So, actual value of exponent will be represented value - 31. Also, we can not have exponent field as all 1's as given in question (usually taken for representing infinity, NAN etc). So, largest value that can be stored is 111110 = 62.
Largest number will be $1.111111111 \times 2^{62-31} = \left(2 - 2^{-9}\right) \times 2^{31}$
Second largest number will be $1.111111110 \times 2^{62-31} = \left(2 - 2^{-8}\right) 2^{31}$
So, difference between these two numbers $=  \left(2 - 2^{-9}\right) \times 2^{31} - \left(2 - 2^{-8}\right) \times 2^{31}\\= 2^{31} \left[\left(2 - 2^{-9}\right) - \left(2 - 2^{-8}\right) \right] \\= 2^{31} \left[ 2^{-8} - 2^{-9} \right] \\= 2^{31} \times 2^{-9} = 2^{22}$
answered by Active (1k points)
edited by
Why not just take m= 0 1st time  and m=1 second time. while exponent is 62 .

is it neccesry to take two maximum number. B/c b/w any two no. difference will be same na.
Yes, it is necessary to take the top 2 maximum numbers as the question is asking about two successive real numbers and they will only give the maximum difference.
What of we take 0's from both sides.+0 and -0??I know its silly question,but does this count as successive real number beacause in floating point we have diffferent representation for both which differ by sign.If i draw on number line then after -0 i will got to -ve underflow which will be rounded to -0.But still does this count as two successive numbers?
No, they donot count as two successive numbers. Although one can represent +0 and -0 by floating point but they are exactly same on number line.
Even if you take m = 3 and m = 2, the answer will be the same.No need to take extreme numbers.
@Ashish  nice explanation.. Thanks :)
+12 votes

The gap between two succesive numbers is small towards the minimum value and maximu towards the maximum value.

Fist Maximum:

0(sign) 111110 (Biased Exponent) 111111111 mantissa

Second Maximum

0(sign) 111110 (Biased Exponent) 111111110 mantissa

E=62 that is biassed exponent since said not all 1's .

DIfference   = (1+1-2-9)*2E-31 - (1+1-2-8)*2E-31

                   =(2-2-9)*2E-31 - (2-2-8)*2E-31

                      = (2-2-9)*262-31 - (2-2-8)*262-31

                      =231 * [(2-2-9) - (2-2-8) ]

                    =222 should be the ans.

answered by Boss (25.8k points)

If we had to find minimum difference between two successive real number..then we will follow i right?

Fist Minimum:

1(sign) 111110 (Biased Exponent) 111111111 mantissa

Second Minimum

1(sign) 111110 (Biased Exponent) 111111110 mantissa

Difference = first minimum - second minimum

Biased exponent should be all 0's ....and mantissa having all 0's for first minimum and for second minimum....all 0's except least significant bit....
OK got it



My previous approach will again give the maximum difference considering -ve real number

Gabbar , 

The gap between two succesive numbers is small towards the minimum value and maximum towards the maximum value. 

The max difference is dictated by the exponent , which in this case = 62 , but I didnot get the part why does the mantissa have to be 111111111 and 111111110 , 

As any two succesive numbers has difference of 1 ( 10 - 9 = 1) , so if take any two successive mantissas their difference will always be 000000001.

So only E = 62 should determine the max difference right , as the difference remains constant 

Where am I going wrong ?

Ok, I have this very silly doubt, when finding decimal equivalent of mantissa:


By the given formula, $(1+(1-\frac{1}{2^9})*2^{-9})*2^{31}=(1+2^{-9}-2^{-18})*2^{31}$

Why not this?

@Sukannya ,In the question,it is given that "m" is the number which is represented in binary...So According to question , maximum value of m =(111111111)2 =  (29 - 1)10    ... So, Now , by  given formula ,

(1+m×2−9) = (1+(29 - 1)*2-9) = (1+1-2-9) = 2- 2-9

Actually , Normal (-1)s * (1.m) * 2E-Bias  and given formula both are same .. 1.m = 1+ 0.m 0.m can be replaced with (m in decimal)*(2-no.of bits in m )...We can prove it by counter examples...

For Example , (0.111)2 = (1-2-3)10 can be represented as ((111)in decimal)*2-3 in decimal which is (23 -1)*2-3  = 1-2-3 ...So , both are same...If I am wrong then please correct me..


@ankitgupta.1729 suppose we take (0.111)2 = (1-2-3)10=7/8 and also $\frac{1}{2}+\frac{1}{2^2}+\frac{1}{2^3}=\frac{7}{8}$, so both the ways should have given same answer here, ryt?

I am really confused here.

@Sukkanya , Forget about formula...Use basics ...

0.001 in binary...Now convert it into decimal :-  0*(1/2) + 0*(1/22) + 1*(1/23) = 2-3 in decimal

Now 0.001 in binary , shift decimal point 3 positions right side.. So its equivalent decimal becomes (001 in decimal)*2-3 ..This is what formula is doing here..

If u don't believe it..then take another base...let's take octal number..

For example ,(0.53)8 ..Now its equivalent decimal = 5*(1/8) + 3*(1/82) = 43/64

Now  , (0.53). ..Shift decimal point by 2 positions ..So, its equivalent decimal becomes (53 in decimal)*8-2 = (5*81 + 3*80 )*8-2 = 43*8-2 = 43/64 ...It is same as above...


@ankitgupta.1729, problem is not with basics, problem is here: 0.111111111=1-2-9, ryt? Now putting it in th given formula (1+(1-2-9)*2-9)*231 according to me but by solution, (1+(1-2-9))*231, that I am not understanding as 2-9 is already embedded in the formula.


@Sukannya , You are putting value of 0.m in the given formula in place of m...we have to put just value of m in the given formula in place of m....formula is already built in the implicit normalized form... So , just put value of m in the given formula...formula will automatically convert into fractional m = 111111111 = 2- 1..Now put in formula (1+(2- 1)*2-9)  = 1+ 1 -2-9 = 2 - 2-9

Ya, @ankitgupta.1729, it was really a silly doubt. Sorry for the inconvinience
No problem...
For a particular exponent the difference between two successive mantissa value is same .but for a smaller exponent the difference between two successive mantissa is always smaller than the difference between two successive mantissa for higher value exponent.....because of which we say that the numbers present densely near by 0 and present sparsely when we go away from 0....but this statement is in context of the exponent....
+8 votes

Exponent grows and makes no. larger, so we take adjacent values at extremes. Exponent have to be taken with all 1's except LSB as 0(as all 1's makes no. 0)

  Sign(1 bit) Exponent(6 bits) Mantissa(9 bits)
1st largest no 0=>+ve 111110=>(62)10 111111111=>(511)10
2nd large no 0=>+ve 111110=>(62)10 111111110=>(510)10

diff. = [(1+511*2-9)262-31]   -  [(1+510*2-9)262-31]
      = [1+ 511*2-9 - 1 - 510*2-9 ] 262-31
[1* 2-9]  262-31 
= 2-9+62-31 = 222

answered by Junior (591 points)
edited by
+7 votes

Largest positive number m all 1's exponent=111110=62

Second largest number m 111111110 exponent=111110=62 


answered by Boss (31.4k points)
+6 votes

largest value = 231+511.222

2nd largest value = 231+510.222

so largest difference between them = 222

C . $2^{22}$

answered by Boss (13.5k points)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

38,112 questions
45,619 answers
49,292 users