Repeating fractional binary to decimal.
7 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
Roger Stafford
2013-10-1
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 个评论
Roger Stafford
2013-10-1
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!