Binary concatenation

4.4k Views Asked by At

In decimal, I have the numbers 4 and 5 for example. I want to concatenate them into the number 45, but then in binary. In decimal, it's just a matter of sticking the numbers together, but I need to do that in binary. I'm not using a programming language, I'm using logical electronic circuitry. But that aside, I need to know how to do it for the general mathematical case if you can call it like that.

4 in decimal = 100 in binary,

5 in decimal = 101 in binary,

45 in decimal = 101101 in binary

As you can see, with binary it's not just a matter of sticking both sequences together. What I need is an explanation of how to get to the answer 45, in binary, by performing arithmetic, number swapping or whatever the two binary sequences that is nessecary.

Thanks for reading, I'd appreciate any help.

2

There are 2 best solutions below

1
On BEST ANSWER

$(45)_{10}$ (i.e., in decimal) is just $$(45)_{10}=5_{10}((4)_{10}+(5)_{10})$$ $(4)_{10}+(5)_{10}$ is in binary, $(100)_{2}+(101)_2=(1001)_2$. Multiply this by $(101)_2$ to get $$(1001)_2\times (101)_2=(1001)_2+(100100)_2$$ This on addition of course gives $(101101)_2=(45)_{10}$.

0
On

At the risk of stating the obvious, we have the following.

If:

  1. $b$ is the function that converts from decimal to binary
  2. $d$ is the function that converts from binary to decimal
  3. and $u+v$ is the concatenation of $u$ and $v$ in decimal
  4. and $x \diamond y$ is the operation of interest

then

$$x \diamond y = b(d(x) + d(y))$$

for all binary strings $x$ and $y$.

I'm not sure if that's what you're looking for, though.