Maker Pro
Maker Pro

Conversion of decimal to binary

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.
 
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
 
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
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??)
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
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.
 
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.
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
 
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

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.
 
Top