I just stumbled across a problem I never actually thought about before: decimals in binary. Can someone explain how to do it? Thanks!
Note: If possible, I'd like the answer in decimals not fractions, but this may not be possible.
I just stumbled across a problem I never actually thought about before: decimals in binary. Can someone explain how to do it? Thanks!
Note: If possible, I'd like the answer in decimals not fractions, but this may not be possible.
$13$ in binary is $8 + 4 + 1 = 1101_2$. $6.5$ is half of thirteen, so move the decimal place once: $110.1_2$.
Using a subscript to denote the base we're writing in, the answer is
$$6.5_{10}=110.1_2$$
In general, for any base $b$,
$${1\over b}=0.1_b$$
"decimals" in other bases are done the same way as regular decimals: just as $6.5 = 6\frac{5}{10}$, $110.1_2=110_2\frac{1_2}{10_2}=6\frac{1}{2}$.
Similarly, $5.25=5\frac{1}{4}=110_2\frac{1_2}{100_2}=101.01_2$.
You can also do other fractions; if the denominator is not a power of 2, the answer will repeat just like for decimals. To calculate, do long division.
3 into 1 goes 0, remainder 1 - digit is 0 before the binary point.
Double 1, get 2
3 into 2 goes 0, remainder 2 - digit is 0 after the binary point.
Double 2, get 4
3 into 4 goes 1, remainder 1 - digit is 1
Double 1, get 2
3 into 2 goes 0, remainder 2 - digit is 0
so 1/3 = 0.0101010101 in binary.
In the same way, 1/5=0.001100110011, and 1/10=0.00011001100110011...
Multiply by 2 so that it becomes an integer, 13.
13 is odd so the last digit equals 1. Subtract 1, divide by 2 to determine the next digit to the left:
12/2 = 6
6 is even so the next digit is 0.
Divide by 2 to determine the next digit:
6/2 = 3
3 is odd so the next digit is 1.
Subtract 1 and divide by 2 to determine the next digit:
(3 - 1)/2 = 1
We thus have:
$$ 13 = 1101_2 \Longrightarrow$$
$$6.5 = 110.1_2$$