It is well-known that 3 1 cannot be represented using a finite a finite decimal representation. 3 1 = 0 . 3 3 3 … .
Neither can it be represented using a finite binary representation. 3 1 = 0 . 0 1 0 1 0 1 … 2
If we had just 24 bits to store the decimal part of this value, the closest rational number we could store in binary would be
1 6 7 7 7 2 1 6 5 5 9 2 4 0 5
What is the closest rational number to 0 . 1 that we could store using binary floating points with only 24 bits (assuming all the 24 bits are being used to store the fractional part of the value)?
If the value comes out to be b a , where a and b are coprime positive integers , submit your as a + b .
Assume that the point occurs before all the 24 bits. So,
111111111111111111111111
will be interpreted as
0.111111111111111111111111
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Exactly! And I was wondering why that was wrong.
Aha! I made the mistake of assuming that the closest approximation has to be less than 0 . 1 and wound up finding 1 6 7 7 7 2 1 6 1 6 7 7 7 2 1 . Silly!
As 0 . 1 = 1 6 7 7 7 2 1 6 1 6 7 7 7 2 1 . 6 , therefore the closest integer numerator will be its rounded value, 1677722
Since the number formed of the last two digits (22, even) of the numerator is not divisible by 4 (therefore the numerator itself is neither) and the denominator ( 2 2 4 ) has only the 2 as prime factor , therefore gcd(1677722,16777216)=2, meaning, that we can only simplify by 2 (in order to make the numerator and the denominator coprime).
Hence,
1 6 7 7 7 2 1 6 1 6 7 7 7 2 2 = 8 3 8 8 6 0 8 8 3 8 8 6 1
and the solution is
8 3 8 8 6 1 + 8 3 8 8 6 0 8 = 9 2 2 7 4 6 9 .
Edit: See Arjen's solution below
To go from 3 1 to 0 . 3 3 … , one simply divides .
Similarly, we want to divide 1 0 1 0 2 1 in binary. That yields 0 . 0 0 0 1 1 0 0 1 1 0 0 1 1 … 2
In other words, we have Σ i = 1 ∞ 2 4 i + 1 3 = 1 0 1
If we had 24 bits, we would set represent it as
0.000110011001100110011001
which translates to
1
6
7
7
7
2
1
6
1
6
7
7
7
2
1
(This solution was originally marked correct. However, the answer was obtained by rounding down to the nearest 24-decimal binary value, while rounding up gives a closer approximation.)
Problem Loading...
Note Loading...
Set Loading...
Relevant wiki: Number Base - Problem Solving
One way to represent 0 . 1 1 0 in binary is by performing a long division. Another approach is to notice that 0 . 1 = 2 1 ⋅ 3 ⋅ 1 5 1 = 2 1 ⋅ 3 ⋅ ( 1 6 1 + 2 5 6 1 + ⋯ ) = k = 0 ∑ ∞ 3 ⋅ 2 − 4 k − 5 . Either way, we find the repeated binary fraction
0.1 = 0.0001 1001 1001 1001 1001 1001 (1001 ...)
Because the 25th decimal is 1, rounding upward results in a smaller error than rounding downward:
0.1 ~ 0.0001 1001 1001 1001 1001 1010
This is the closest 24-decimal binary approximation of decimal 0.1. Writing this as a normal fraction, we get 2 2 4 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 0 2 = 1 6 7 7 7 2 1 6 1 6 7 7 7 2 2 = 8 3 8 8 6 0 8 8 3 8 8 6 1 , so that the answer should be 9 2 2 7 4 6 9 .