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!