# Conversion of decimal to binary

Discussion in 'General Electronics Discussion' started by sachin_sh, Feb 11, 2018.

1. ### sachin_sh

2
0
Feb 11, 2018
hi,
I want to ask how to convert decimmal no.
124.375 into 8 bit binary digit no.
(i.e i having problem that, i should count binary digit from left side or right side as it exceeding the 8 bit).

thnks.

2. ### flippineck

269
9
Sep 8, 2013
from
https://www.rapidtables.com/convert/number/decimal-to-binary.html

124,375 ---> 11110010111010111

124.375 ---> 1111100.011

I think the number just grows from the right, same as base 10 does?

i.e.
0 --> 0
1 --> 1
2 --> 10
3 --> 11
4 --> 110
5 --> 111
6 --> 1000
.
.

rightmost figure is the 'ones' column, second to rightmost is the 'twoes'. 3rd to rightmost the 'fours', 4th to rightmost the 'eights' and so on.. 16..32..64..128..256..512 etc working toward the left

3. ### sachin_sh

2
0
Feb 11, 2018
what i want to ask is,
for ex.
lets just say if i want to write a decimal;
124.375 in 3 digit then i will write 124 only
and if in 4 digit then i will go with 124.3

Similarly, for binary number 1111100.011
what should i write for 8 bit?
(from what you say , i should go with 11100.011 right??)

4. ### (*steve*)¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥdModerator

25,411
2,779
Jan 21, 2010
I would suggest that you should round off the fractional portion and store the whole number portion as 0111000.

8 bits is enough to store the numbers 0 to 255, or -128 to 127, or 0 to 127.5, or -64 to 63.5. or a whole lot of other options depending on how you decide to represent the number in binary.

However, you need to decide on a single representation, because otherwise there's no way to know that (for example) the number 11111110 is 254, -127, -63.5, or any of a plethora of different values.

Cannonball likes this.
5. ### Ratch

1,079
330
Mar 10, 2013
As others have shown you for the binary integer, keep dividing the decimal integer by 2 and build the binary integer from right to left from the remainders. For the fractional part, multiply the decimal part by 2 and build the fractional binary from the overflow into an integer. Example: 0.375 * 2 = 0.75, no overflow, so first fractional binary digit is 0. Next, 0.75 * 2 = 1.5, overflow, so second fractional binary digit is 1. Next, 0.5 * 2 = 1.0, overflow, so third fractional binary digit is 1. Putting it all together we get . 011 for the binary fraction.

Ratch

6. ### ChosunOne

372
90
Jun 20, 2010
I'm surprised nobody else bothered to correct this in your sample example:

0=0
1=1
2=10
3=11
4=100
5=101
6=110
7=111
8=1000

There are 10 kinds of people: Those who understand binary and those who don't.

There are 10 other kinds of people: Those who understand trinary, those who don't, and those who have never heard of it.

Harald Kapp likes this.
7. ### flippineck

269
9
Sep 8, 2013
ChosunOne - absolutely! sorry about that, you're quite correct ;-)