The simple math behind decimal-binary conversion algorithms #120
Replies: 4 comments 3 replies
-
Very well explained, but it seems the last term of the polynomial for fractional number is wrong. It should be |
Beta Was this translation helpful? Give feedback.
-
This article was so helpful! I had trouble understanding why it was that decimals needed to *2. Thank you for taking the time to explain not only how to do it but also how it works. :) |
Beta Was this translation helpful? Give feedback.
-
"Now, if x2 is equal to 0, then the sum of left side of the expression cannot be greater than 1, but the left side is 1.5, so x1 must be 1 and the remaining part 0.5." - @maxkoretskyi I think you meant "x2 must be 1", right? |
Beta Was this translation helpful? Give feedback.
-
@maxkoretskyi "Well, for a number to be finitely represented the denominator in a fraction should be a power of the system base" - I don't think this condition is sufficient. For example, 5 is not a power of 10, yet 1/5 can be finitely represented in the base 10. "For integers p and q with gcd(p, q) = 1, the fraction p/q has a finite representation in base b if and only if each prime factor of q is also a prime factor of b." |
Beta Was this translation helpful? Give feedback.
-
This article explains the very basic math behind four simple algorithms to convert binary to decimal: two for integer and two for fractions.
Read the article here.
Beta Was this translation helpful? Give feedback.
All reactions