# Interpretation of '1/3' in IEEE floating point representation

For a rational number 1/3 below is the floating point representation(64 bit) of decimal expansion 0.3333333....

## As per the above bit structure, I would like to interpret the value of exponent(11 bits) and value of fraction(52 bits).

exponent has 11 bits. How do I interpret exponent value?

fraction has 52 bits. Here 0101 is decimal 5. Am not sure if we captured fractional part 33333333... of decimal expansion? To capture fractional part am I suppose to expect 0011 pattern instead of 0101. How do I interpret fractional part?

• Floating point represents a number in binary but not by coding the individual decimal digits in binary. The same happens with integers: the decimal number 23 is coded as $0001\,0111$ ($2^4+2^2+2^1+2^0$), not $0010\,0011$ ("two and then three"). – David Richerby Feb 25 '15 at 7:49
• That image is all but indecipherable. Please get a better image and, in any case, retype the actual representation. – Raphael Feb 25 '15 at 8:14
• Mantissa is 1 (implicit) + 0*(1/2)+1*(1/4)+0*(1/8)+1*(1/16) ... = 1.33333. Exponent is coded with a bias equal to 011 1111 1111. So here your exponent is 2^(-2)=1/4. 1.3333/4 = 0.3333 – TEMLIB Feb 26 '15 at 1:53

The fractional part is in binary: $(0.01010101\ldots)_2 = (0.333333\ldots)_{10}$. To convince yourself of this, try multiplying the binary $0.0101010101\ldots$ by $3$: you will get $0.111111\ldots = 1$. In a similar way, the decimal $0.0101010101\ldots$ equals $1/99$.
The mantissa (fractional part) in fact has an implicit $1.$ in front, so it actually equals $(1.01010101\ldots)_2 \approx 4/3$. The exponent should therefore be $-2$, since $1/3 = 4/3 \cdot 2^{-2}$. The exponent itself is stored with an offset of $1024$ (or more generally, $2^{w-1}$, where $w$ is the width of the exponent field), that is, instead of $-2$ we actually store $1022$, which in binary reads $01111111101$.
You should note that the floating point number doesn't represent $1/3$ exactly, rather a number pretty close to $1/3$. The only numbers representable exactly in floating point (given enough precision) are dyadic numbers, which are numbers of the form $A/2^B$ (for integer $A,B$).
• In python, >>> 1/3 == 0.333333333333333 gives False. >>> 1/3 == 0.3333333333333333 gives True. How do I understand this? – overexchange Mar 10 '15 at 11:55
• In other words, If 52 bits are 0101010101010101010101010101010101010101010101010101 as mentioned in the above query, then how many exact number of 3's come after the decimal? – overexchange Mar 10 '15 at 12:41
• There is no exact number of 3's after the decimal. For example, $(.01)_2 = 0.25$, $(.0101)_2 = 0.3125$, $(.010101)_2 = 0.328125$, $(.01010101)_2 = 0.33203125$, and so on. Those numbers approach $1/3$, but not via the decimals $0.3,0.33,0.333,\ldots$. – Yuval Filmus Mar 10 '15 at 14:18