# How to convert Decimal numbers into Binary numbers?

Binary numbers is an special numbers which is made up of only two digits 0 & 1 .
How to convert decimal numbers in binary no
I have two approach to do it .

1. Left to right method
2. Right to left method

I know both techniques very well, and I always use left to right method only in mind .
But I tell you both techniques.

How they work?
**
Left to right method
**
I show you this method with an example
Binary number of 25
To find this - First think which is the nearest power of 2 here .
It can done easily in mind.
I got it nearest power of 2 here is 16 - (2^4)
We donāt take 32 (2^5) because it is greater than 25.
Now we go in decreasing order of 2 power in mind.
Our aim is to make 25 with adding of 2 power.
16 > 8 > 4 > 2 > 1
1 1 0 0 1
16 + 8 + 1 = 25
The digits which we choose for adding to make 25 numbered 1 and that we donāt take is numbered 0
Note : first we take 16 and after this take 8
Now it becomes 24 . Now we do not take 4 & 2
because when adding it becomes greater than 25.
Another example -
Binary number of 156
128>64>32>16>8>4>2>1
1 0 0 1 1 1 0 0
First we chose 128. (1)
Then we donāt take 64 & 32 because after adding this no. became bigger than 156. (00)
Then we take 16 so our no. became 144 (1)
And then we choose 8 , now it is 144+8 =152 (1)
And last we take 4 , so finally we get 152+4 = 156(1)
And now our no. is complete so for 2 & 1 (00)

Example -
Binary number of 4576
4096 2048 1024 512 256 128 64 32 16 8 4 2 1
= 1000111100000
**
Right to left method
**
In this method, we are halving the number until 1 is not come (Remainder is not considered except 1)
We take 1 for odd numbers and 0 for even numbers.
Example
65
First we half the number.
1 < 2 < 4 < 8 < 16 < 32 < 65
Now we write this in binary form
1000001
If you donāt know what is binary , decimal system and want to learn number system you can visit

https://en.m.wikipedia.org/Wiki/Numeral_system

2 Likes

Alternatively, first do dec2hex and then hex2bin. The latter you can read straight off with a little bit of practice, the former is multiples of 16.

Makes most sense in the range 0 ā¦ 255 but thatās usually what it is anyway.

1 Like

@bjoern.gumboldt
Can you give me , some example that you can say. and method of working.

100_{10} = {\color{red}{6}}{\color{green}{4}}_{16} = 0110\ 0100_{2} \\
\frac{100}{16} = {\color{red}{6}}\frac{{\color{green}{4}}}{16} \\
1. Take the \color{red}whole\ number part of the mixed fraction for your your left-hand-side (lhs) and the \color{green}numerator for your right hand side (rhs).
a) Write lhs as binary {\color{red}{6}}_{16} = 0110_{2}
b) Write rhs as binary {\color{green}{4}}_{16} = 0100_{2}

Another example:

200_{10} = {\color{red}{C}}{\color{green}{8}}_{16} = 1100\ 1000_{2} \\
\frac{200}{16} = {\color{red}{C}}\frac{{\color{green}{8}}}{16} \\

ā¦you can think of C as 12 if you prefer base10 notation. This works without much effort up to 16^2-1:

255_{10} = {\color{red}{F}}{\color{green}{F}}_{16} = 1111\ 1111_{2} \\
\frac{255}{16} = {\color{red}{F}}\frac{{\color{green}{F}}}{16} \\

Things you need to know for this method:

• A - F in binary
• 16 times table
1 Like

@bjoern.gumboldt
Can you tell me how can you typing colourful words.

Thanks for explaining binary.
Your method, working for how many numbers?

No idea what you meanā¦ itās a simple base conversion; it works for all the numbers.

16=2^{\color{red}{4}}

Thus converting from base _{16} \to base _{2} gives you \color{red}4 digits in binary for each digit in hexadecimal.

FEC84210_{16}=1111\,1110\,1100\,1000\,0100\,0010\,0001\,0000_2
1 Like

Just type \color{red} (or any other color) inside Latex commands.
For example:

10^{\color{red}2}

$10^{\color{red}2}$

2 Likes

For beginners I use the following technique:

If the number is odd write a 1 and subtract 1. If even, write 0.
Now half.
Repeat and write the new numbers to the left.

Example of 100, like above:

100 is even: 0
50 is even: 00
25 odd: 100
12: 0100
6: 00100
3: 100100
1: 1100100

Done. However, should you repeat:
0: 01100100

I think it was already stated above, but going from binary to hexadecimal is just splitting the number in parts of 4 = 0110 0100 and converting each part into hex: 64.

100_{10} = 0110\ 0100_{2} = 64_{16}

That is then the reverse of what I was saying earlier. I think for people comfortable in base 2, 8, and 16 (or at least for me) the 96 as a multiple of 16 would be very obvious when it comes to 100. So thatās 6 with a remainder of 4. Now just write first 6 and then 4 as binary; and done.

Agreed, thatās a very easy techniqueā¦ especially for younger students that are not yet familiar working in different bases. Obviously, it involves more stepsā¦ but taking half and half over and over is really hard not to understand.

1 Like

Yes, thatās what I thought.

Absolutely!
If you know that 96 is 6 * 16 - which most people with an interest in mental calculation probably do - then it indeed becomes a lot easier.

100 decimal = 96 + 4 = 64 hex.

And yes, then 64 hex is easy to translate to binary.

For people who donāt know me. My father was a director at IBMās.
I was born in 1967 and made toddler drawings on programming punch cards, like these:

He would bring boxes full of these things!

Also he would tell us about the binary and hexadecimal system and its use.
I remember doing hexadecimal long division while in a restaurant when I was young.

It helps mental calculation a lot when you can do these conversions easily, so I heavily advise to do these.

For a while just take each decimal number and convert to hexadecimal.
167 decimal = 160 + 7 = 10 * 16 +7 = A7 Hex.

Easy peasy!

5 Likes

Of course another way to convert dec2bin is via octalā¦ taking your example 167:

2 x 64 = 128 leaves you with 39
4 x 8 = 32 leaves you with 7
7 x 1 = 7

For people who wonder where these multipliers come from: 8Ā² = 64; 8Ā¹ = 8; 8ā° = 1

247ā = 010 100 111ā = A7āā = 1010 0111ā

Pro: 0 - 7 to bin is the same from oct as it is from hex
Con: 64 (i.e., 8Ā²) happens 4x earlier than 256 (i.e., 16Ā²)

Lolā¦ thatās awesome!

I was asked to explain how this works.

If number is odd the last digit is 1 in binary.
If a number is even the last digit is 0 in binary.

Subtracting one in case of is odd and dividing by two removes the last digit.

If I repeat this I discover the most right digit at each step and subsequently remove it.

So one by one I discover digit by digit.

Can I use the same system for octal and other bases? Sure!

Letās take the above example of 167 (decimal).
The nearest number divisible by 8 is 160.
So subtract 160 from 167 to get 7.
That is the most right number.

Continue with 160.
Divide this by 8 to get 20.
Nearest multiple of 8 below 20 is 16.
Subtract 16 from 20 to get 4.
Result now is 47.

Continue with 16
Divide this by 8 to get 2.
Nearest multiple of 8 below 2 does not exist so we are done.

Result is 247.

2 Likes

This works fantastically!

And what I just explained is the reverse of what you do.

Well, I guess itās time to drive this point home then for future readers of this post: if you want to convert to base _2, you can use 2^x as an intermediary base; where x will be the number of bits when converting from base _{2^x} \to base _2.

So one last time 167 but this time in base _{32}; and since 2^5=32 we know that bits will be in groups of 5.

\frac{167}{32} = {\color{red}{5}}\frac{{\color{green}{7}}}{32} \\

{\color{red}5_{32}}=00101_2 ;\ {\color{green}7_{32}}=00111_2

ā“ 167_{10}={\color{red}5}{\color{green}7}_{32}=00101\ 00111_2

1 Like

Ok, letās do something that is never used: base 11.

If we use A through F for the extra symbols in hex, we need only āAā for base 11.

So 10 decimal is āAā base 11.

Letās convert 167_{10} again.

Here is how I do this.

My mind goes:

100_{11} = 11_{10} \,\,^2 = 121_{10}
In plain English; 100 in base 11 is 11 squared, is 121.

167 - 121 = 46 left to be done (decimal).

Closest factor of 11 in 46 is 44.
Of course 44 = 11 * 4, so add 40_{11} to 100_{11} to get 140_{11} .

Last step 46 - 44 = 2 and 2 < 11 so just add 2 to 140_{11} to get:
142_{11}.

3 Likes

How about 2i as the base?

167_{10}=102030303_{2i}

ā¦or we could pretend that the 1010 0111 weāve been getting was quater-imaginary instead of binary and convert it to decimal:

1010 0111_{2i}={\color{gray}{-128i+32i-4+2i+1}}=-94i-3

1 Like

How do you know which number represents a 0 and what number represents an 1?

Example - 156

128 > 64 > 32 > 16 > 8 > 4 > 2 > 1

10011100

Note: first our aim is to find nearest 2ās power , then write 2ās power backwards.

Last step -

128 - 1 (128)
64 - 0 not chose because if we add 64 in 128 then it becomes 128+64= 192 that is greater then the original number 156.
32 - 0 (not chose)
16 - 1 (128 + 16 = 144)
8 - 1 (144 + 8 = 152)
4 - 0 ( 152 + 4 = 156)
2 - 0
1 - 0

wHaT?