Decimal to binary and hexadecimal conversion

weller7503

New member
Joined
Jan 31, 2012
Messages
1
I have just started a new class, I have never done this before I will give an example of the problems. Can someone please help me understand how to do this?

Thanks



Decimal

2678 need to convert this to binary and hexadecimal
 
Binary is easy, you'll see :)

What is the largest base 2 number you can get in 2678?

It's 11, and \(\displaystyle 2^{11} = 2048\)

So, in binary, you'll need at least 12 digits (11+1), and this would look like:

100000000000

This is 2048. What is left now? 2678 - 2048 = 630

Repeat again, and you'll see that \(\displaystyle 2^9 = 512\)

Since it's 9, you put a '1' in the (9+1)th digit, starting from the right:

101000000000

This is 2048+512.

Rinse and repeat, you'll get 118 left, meaning \(\displaystyle 2^6\);

101000010000

Again and you'll get 54, meaning \(\displaystyle 2^5\);

101001100000

Again and you'll get 22, meaning \(\displaystyle 2^4\);

101001110000

Again and you'll get 6, meaning \(\displaystyle 2^2\);

101001110100

Again and you'll get 2, meaning \(\displaystyle 2^1\);

101001110110

And now that's it since you are left with nothing this time! (2-2 = 0)

If you want to get the decimal number again, just do: \(\displaystyle 2^{11} + 2^9+2^6+ 2^5+2^4+2^2+2^1\) (Notice again that the power is the position of '1' in the binary number, minus 1)

Now to convert to hex, I think it's better you have a table of conversion with you, because:
Binary | Hex
0000 = 0
0001 = 1
0010 = 2
0011 = 3
0100 = 4
0101 = 5
0110 = 6
0111 = 7
1000 = 8
1001 = 9
1010 = A
1011 = B
1100 = C
1101 = D
1110 = E
1111 = F

You can always re-create that table, it's easy if you notice the pattern. BUt don't forget that it ends at F, or remember that F is the 6th letter and hex means 6, or just remember that it goes up to 1111 (which by the way means \(\displaystyle 2^3+2^2+2^1+2^0 = 15\))

So, let's take the binary we got earlier:

101001110110

Break it down in groups of 4 digits for the conversion: 1010 0111 0110

Look at your table and you should get 'A76'. :)
 
I have just started a new class, I have never done this before I will give an example of the problems. Can someone please help me understand how to do this?

Thanks

Decimal

2678 need to convert this to binary and hexadecimal
I think the simplest way to look at it is: Conversion to base X is repeated division by X --

2678 / 2 = 1339, rem 0. So 0 is your last (rightmost) digit.
1339 / 2 = 669, rem 1. 1 is your next (to the left) digit.
etc.
until your quotient is zero.

Now, about base X bigger than 10, such as 16? Do the same thing, exactly. But what if the remainder is bigger than 9? Simply create new symbols for the 'digits'. The usual is A = 10,....,F = 15.
 
Hello, weller7503!

Convert 2678 to binary and hexadecimal.

SamuelK is right . . . There is a faster procedure.

To convert to base-2:
. . (1) Divide the number by 2; note the remainder.
. . (2) Divide the quotient by 2; note the remainger.
. . (3) Repeat step (2) until we get a zero quotient.
. . (4) Read up the remainders.

Code:
      2 ) 2 6 7 8     Remainders
        ----------
      2 ) 1 3 3 9         0
        ----------
        2 ) 6 6 9         1
          --------
        2 ) 3 3 4         1
          --------
        2 ) 1 6 7         0
          --------
          2 ) 8 3         1
            ------
          2 ) 4 1         1
            ------
          2 ) 2 0         1
            ------
          2 ) 1 0         0
            ------
            2 ) 5         0
              ----
            2 ) 2         1
              ----
            2 ) 1         0
              ----
                0         1
Therefore: .\(\displaystyle 2678 \;=\;101,\!001,\!110,\!110_2\)



To convert to base-16:
. . (1) Divide the number by 16; note the remainder.
. . (2) Divide the quotent by 16; note the remainder.
. . (3) Repeat step (2) until we get a zero quotient.
. . (4) Read up the remainders.

Code:
      1 6 ) 2 6 7 8     Remainders
          ----------
        1 6 ) 1 6 7         6
            --------
          1 6 ) 1 0         7
              ------
                  0        10
The remainders are 10, 7, 6.

For "digits" greater than 9, use: .A = ten, B = eleven, C = twelve, . . .

Therefore: .\(\displaystyle 2678 \;=\;A76_{16}\)
 
Top