How do I convert a number with a decimal point to binary?

In summary, converting a decimal number to binary form can be done by first separating the integer and fractional parts. The integer part can be easily converted to binary, while the fractional part can be approximated using a method of multiplying by 2 and keeping track of the surplus. However, for some decimal numbers, such as 0.3, an exact conversion to binary is not possible and can only be approximated.
  • #1
xod_s
8
0

Homework Statement



I don't know how to convert the number 148.3 to binary form.


Homework Equations



Just having a decimal point really throws in a monkey wrench in the "keep dividing by and if a number halfed has a decimal point ignore the after decimal point stuff two" procedure.



The Attempt at a Solution



I got the answer 101010001 but I looked the answer up and it's apparently 10010100.How can this be?.I was desperate enough to just look up the answers but I still don't how 200.45 can be 11001000,100.9 can be 1100100 and 9001.375 can be 10001100101001

If it helps me teacher wrote a note that looks like this ...

{want to convert to 0.7 decimal to binary -->
*multiply by 2 and list surplus (0,1) 0.7 decimal=0.1011001100
½,¼,1/8,1/16, 1/128,1/256




surplus 0.7*2
______________
I 1 I .4*2
I 0 I .8*2
V 1 I .6*2
read down 1 I .2*2
0 I .4*2
0 I .8*2
1 I .6*2 }
 
Physics news on Phys.org
  • #2
xod_s said:

Homework Statement



I don't know how to convert the number 148.3 to binary form.


Homework Equations



Just having a decimal point really throws in a monkey wrench in the "keep dividing by and if a number halfed has a decimal point ignore the after decimal point stuff two" procedure.



The Attempt at a Solution



I got the answer 101010001 but I looked the answer up and it's apparently 10010100.
Let's look at things in two parts: the integer part and the fractional part.

The integer part is 148, which is 9416 in hexadecimal (i.e., base-16). The nice thing about hex is that it is so easy to convert to binary. You just convert each hex digit.
916 = 1001
416 = 0100

So 14810 = 9416 = 100101002, which agrees with the answer you looked up. Note that this doesn't include the fractional part, .3.

I'll leave that to you, after you've read my comments below.




xod_s said:
How can this be?.I was desperate enough to just look up the answers but I still don't how 200.45 can be 11001000,100.9
Typo?
xod_s said:
can be 1100100 and 9001.375 can be 10001100101001
I don't see how it can be, either. Just as your decimal fraction has a decimal point, your binary fraction will need a "binary" point, to separate the integer part from the fractional part.
xod_s said:
If it helps me teacher wrote a note that looks like this ...

{want to convert to 0.7 decimal to binary -->
*multiply by 2 and list surplus (0,1) 0.7 decimal=0.1011001100
½,¼,1/8,1/16, 1/128,1/256




surplus 0.7*2
______________
I 1 I .4*2
I 0 I .8*2
V 1 I .6*2
read down 1 I .2*2
0 I .4*2
0 I .8*2
1 I .6*2 }

What seems to be going on in the table is this:

Start with the fractional part -- 0.7
Multiply it by 2 to get 1.4. Save the part to the left of the decimal point, 1.
Take the new fractional part -- 0.4
Multiply it by 2 to get 0.8. Save the part to the left of the decimal point, 0.
Take the new fractional part -- 0.8
Multiply it by 2 to get 1.6. Save the part to the left of the decimal point, 1.
Take the new fractional part -- 0.6
Multiply it by 2 to get 1.2. Save the part to the left of the decimal point, 1.
etc.

This means that .710 ≈ .1011...2

The binary fraction means 1 * 1/2 + 0 * 1/4 + 1 * 1/8 + 1 * 1/16. If you add these up you get .6875, which is a little smaller that .7. I stopped the process early, so I left off some terms, which makes my result a little small. The more terms you add, the closer you'll get to .7.

I should mention that some decimal fractions that have nice compact forms in base-10 have infinitely long representations in binary, and 0.7 is one such number.
 
  • #3
xod_s said:

Homework Statement



I don't know how to convert the number 148.3 to binary form.


Homework Equations



Just having a decimal point really throws in a monkey wrench in the "keep dividing by and if a number halfed has a decimal point ignore the after decimal point stuff two" procedure.



The Attempt at a Solution



I got the answer 101010001 but I looked the answer up and it's apparently 10010100.How can this be?.I was desperate enough to just look up the answers but I still don't how 200.45 can be 11001000,100.9 can be 1100100 and 9001.375 can be 10001100101001

If it helps me teacher wrote a note that looks like this ...

{want to convert to 0.7 decimal to binary -->
*multiply by 2 and list surplus (0,1) 0.7 decimal=0.1011001100
½,¼,1/8,1/16, 1/128,1/256




surplus 0.7*2
______________
I 1 I .4*2
I 0 I .8*2
V 1 I .6*2
read down 1 I .2*2
0 I .4*2
0 I .8*2
1 I .6*2 }

The decimal part 0.3 cannot be converted exactly to binary for any finite number of bits after the decimal point. The approximation .1011001100 evaluates to 179/256 ≈ 0.69921875.

This issue is well-known to anyone who has written computer codes in Fortran, C, Basic, or whatever: it is the source of some occasional software failures, if the person writing the code does not take care to account for it.

RGV
 
  • #4
A decimal number in some base b is written xy.z (say) where x,y, and z are single digits in that base.

This means that the number is [itex]x\times b^2 + y\times b^1 + z \times b^{-1}[/itex]

So - decimal 0.3 is [itex]3\times 10^{-1}[/itex] and the task is to expand 0.3 in terms of negative powers of 2.

This is a similar process for positive powers.
Thus:
dec[0.5] = bin[0.1]
dec[0.25] = bin[0.01]
dec[0.75] = bin[0.11]
... and so on.

Note, some decimals like 0.1 and 0.3 are recurring in binary ;)

another example
http://answers.yahoo.com/question/index?qid=20090819210335AAYfQaE
 

Related to How do I convert a number with a decimal point to binary?

1. What is the process for converting a number with a decimal point to binary?

The process for converting a number with a decimal point to binary is to first separate the whole number and the decimal part. Then, convert the whole number to binary using the standard conversion method. Next, convert the decimal part to binary by multiplying it by 2 and recording the whole number part. Continue this process until the decimal part becomes 0 or a repeating decimal.

2. How do I convert a decimal number with a repeating decimal to binary?

If the decimal part of the number is repeating, continue multiplying by 2 and recording the whole number part until the pattern repeats or until you have the desired number of binary digits. Then, place the repeating pattern in parentheses and add a bar on top to indicate that it is a repeating decimal in binary form.

3. Can I use a calculator to convert a number with a decimal point to binary?

Yes, most scientific calculators have a function to convert a decimal number to binary. However, it is still important to understand the conversion process in case you encounter a number that cannot be accurately converted by a calculator.

4. Are there any special cases when converting a number with a decimal point to binary?

Yes, there are a few special cases to keep in mind when converting a number with a decimal point to binary. If the decimal number is negative, the process is the same but the final binary number will have a negative sign. Also, if the decimal number is a fraction, the process is the same but the final binary number will have a fraction in binary form.

5. How do I know if I have correctly converted a decimal number to binary?

You can check your answer by converting the binary number back to decimal and comparing it to the original decimal number. If they match, then you have correctly converted the number to binary.

Similar threads

  • Precalculus Mathematics Homework Help
Replies
11
Views
949
Replies
4
Views
1K
  • Precalculus Mathematics Homework Help
Replies
4
Views
3K
  • Precalculus Mathematics Homework Help
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
4K
  • Programming and Computer Science
Replies
3
Views
975
  • Computing and Technology
Replies
4
Views
865
  • Engineering and Comp Sci Homework Help
Replies
9
Views
1K
  • Precalculus Mathematics Homework Help
Replies
7
Views
2K
  • Precalculus Mathematics Homework Help
Replies
7
Views
2K
Back
Top