Convert decimal base to binary

In summary: Actually, you're multiplying by the base you're converting to. In this case, we're multiplying a decimal number by 2 to convert to binary. To convert to hex, you would multiply the decimal number by 16; to convert to octal, you would multiply the decimal number by 8.
  • #1
Trentonx
39
0

Homework Statement


Convert 33.9 to binary.


Homework Equations


Division by two and remainders


The Attempt at a Solution


I'm unsure since it is .9. Using the dividing by two method with the remainders wouldn't account for that. Could I do something like this?
33.9 = 339 *10^-1, convert to binary (101010011) and then account for the scientific notation in some way?
 
Physics news on Phys.org
  • #2
think about the 'divide by two' method with 1/2, 1/4,1/8 etc
 
  • #3
It's easiest if you just do the integer part and fractional part separately. Convert the integer part as usual. For the fractional part, multiply by 2, pick off the integer part, and repeat the process with the new fractional part. For example, for 13/16=0.8125=0.11012, you'd do

0.8125 x 2 = 1.625
0.625 x 2 = 1.25
0.25 x 2 = 0.5
0.5 x 2 = 1.0
 
  • #4
Trentonx said:
Could I do something like this?
33.9 = 339 *10^-1, convert to binary (101010011) and then account for the scientific notation in some way?

You could proceed this way, though it would be cumbersome; it requires long division in binary. 339 = 101010011, and 10 = 1010 (you know how to convert to integers so those two conversions are straightforward). Then do the division: 101010011/1010 (Sorry, I tried to put the long division here but the formatting didn't work.) In any case, you'd find that 33.9 has an infinitely repeating binary equivalent, which is 100001.1(1100) (the part in parentheses is the repeating part).

But @vela's way is the way I recommend doing it.

I have two things on my site that may help you:

This article, with more details on the algorithm: http://www.exploringbinary.com/base-conversion-in-php-using-bcmath/ (see section labeled "dec2bin_f())"

A decimal/binary converter to check your answers: http://www.exploringbinary.com/binary-converter/
 
  • #5
Except for the bit where the binary is infinite, that's not too bad. Thanks for the help. On a related note does vela's way work to convert to octal and hexadecimal the same way?
 
  • #6
Trentonx said:
Except for the bit where the binary is infinite, that's not too bad.
That's just like the fact that the decimal representation of 1/3=0.33333... requires an infinite number of 3s.
On a related note does vela's way work to convert to octal and hexadecimal the same way?
Yes, as long as you realize you're multiplying by the base you're using. Say a number has the base-b representation [itex](0.d_1d_2d_3d_4\cdots)_b[/itex]. When you multiply by b, you shift each digit to the left, so you get [itex](d_1.d_2d_3d_4\cdots)_b[/itex], so the integer part is the first digit in the representation. You can get the subsequent digits by discarding the integer part and repeating the process.
 
  • #7
vela said:
Yes, as long as you realize you're multiplying by the base you're using. Say a number has the base-b representation [itex](0.d_1d_2d_3d_4\cdots)_b[/itex]. When you multiply by b, you shift each digit to the left, so you get [itex](d_1.d_2d_3d_4\cdots)_b[/itex], so the integer part is the first digit in the representation. You can get the subsequent digits by discarding the integer part and repeating the process.

Actually, you're multiplying by the base you're converting to. In this case, we're multiplying a decimal number by 2 to convert to binary. To convert to hex, you would multiply the decimal number by 16; to convert to octal, you would multiply the decimal number by 8.
 

1. What is the decimal base system?

The decimal base system, also known as the base-10 system, is the most commonly used numbering system in the world. It uses ten digits (0-9) to represent all numbers, and each digit's value is based on its position in the number.

2. How does the binary system work?

The binary system, also known as the base-2 system, uses only two digits (0 and 1) to represent all numbers. Each digit's value is based on its position in the number, and the number's total value is the sum of the values of each digit multiplied by its position's power of 2.

3. Why would I need to convert from decimal to binary?

Converting from decimal to binary is necessary when working with computers or other electronic devices. These devices use binary code to represent and process information, so converting decimal numbers to binary allows them to understand and work with the numbers.

4. What is the easiest way to convert from decimal to binary?

The easiest way to convert from decimal to binary is by using the repeated division method. This involves dividing the decimal number by 2 and noting the remainder, then repeating the process with the quotient until the quotient is 0. The binary number is then read by arranging the remainders from bottom to top.

5. Can I convert any decimal number to binary?

Yes, any decimal number can be converted to binary. However, some numbers may result in very long binary numbers due to the nature of the conversion process, so it may not be practical to do so in some cases.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
10
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
10
Views
2K
Replies
4
Views
921
  • Engineering and Comp Sci Homework Help
Replies
2
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
8
Views
5K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
Back
Top