You are on page 1of 4

# Hex -> Binary

For this one, we're just going to follow the reverse procedure. Take each hex digit, find it's decimal equivalent, and then convert that small decimal number to a four-bit binary: Let's try 0x4B9: 9 in hex is also 9 in decimal. Following the procedure in the decimal->binary description, this comes out to 1001b B in hex is 11 in decimal. 11 decimal comes out to 1011b 4 in hex is 4 in decimal. 4 decimal comes out to 0100b Put all those blocks together: 0x4B9 = 010010111001

Hex -> Decimal
You have two choices here. The first, again involves knowing your powers of 16. For that, you'd take each hex digit, and multiply its decimal equivalent by the appropriate power of 16, then sum the results. So our example above: 0x4B9 would come out to: (9 x 1) + (11 x 16) + (4 x 256) As you can see, those are non-trivial computations. Instead, I rather strongly recommend you simply convert from Hex to Binary first, as above, and then follow the Binary->Decimal conversion algorithm to find your final result. Doing that, we find that 0100 1011 1001b comes out to: 1 + 8 + 16 + 32 + 128 + 1024 = 1209

To manually do base-10 to base-n conversions, go through the following steps: 1. Take your original base-10 number and divide it by your new base, n (2 or 16 for your examples, but it works with any base). 2. Prepend the remainder to your new number. If you haven’t been through this step before, then this becomes your least significant digit. 3. If the quotient is greater than the base, go back to step 1, using the new quotient instead of the original number. Otherwise, continue to step 4. 4. Append the quotient to the beginning of the new number. For example, let’s say your original base-10 number is 48879, and you want to convert to base-16. You would go through this process: 1. 48879 / 16 => quotient 3054, remainder 15 (written as "F"). 2. New number is F. 3. 3054 > 16, so go back to step 1. 1. 3054 / 16 => quotient 190, remainder 14 ("E"). 2. New number is EF. 3. 190 > 16, so go back to step 1.

1

Numbering system