Azzera filtri
Azzera filtri

Repeating fractional binary to decimal.

5 visualizzazioni (ultimi 30 giorni)
David
David il 1 Ott 2013
Commentato: David il 2 Ott 2013
Could someone explain to me how to convert the binary decimal (0.1001)2 (repeating) to a decimal in base 10? I know how to do this for regualr binary fractions but not for repeating ones. Thanks.

Risposta accettata

Roger Stafford
Roger Stafford il 1 Ott 2013
It isn't clear to me whether you mean a binary number with a pattern that is repeated some finite number of times, or one that is infinitely repeated. I will assume you mean infinitely repeated, as in, say,
.11010110101101011010.....
which repeats infinitely every five binary digits. Let x be the value of the first pattern (.11010 in the example) and n be the number of binary digits in it. Then the value of the infinitely repeating pattern would be:
y = x/(1-2^(-n))
In the above example it would be y = (26/32)/(1-2^(-5)) = 26/31 = .8387096774
There is a similar formula for one repeated a finite number of times.
  3 Commenti
Roger Stafford
Roger Stafford il 1 Ott 2013
If m is the number of times the pattern is given, then
y = x*(1-2^(-n*m))/(1-2^(-n))
In the example I gave, if m = 4 for .11010110101101011010, it would be
y = 26/32*(1-2^(-5*4))/(1-2^(-5)) = 26/31*(1-2^(-20)) = .8387088776
Note: These answers assume the binary point is just to the left of the first pattern. If it is elsewhere make the necessary adjustment with the appropriate multiple of a power of 2.
David
David il 2 Ott 2013
Thanks for the response. Great help.

Accedi per commentare.

Più risposte (0)

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by