|
Decimal, Binary, Octal and Hexadecimal Number Conversion
(Page 2 of 4)
Conversions Between Binary, Octal and Hexadecimal
Okay, let's start with the easy stuff
first. Conversion between binary, octal and hexadecimal is very simple,
as you may have noticed in the
preceding topic, where I introduced them.
Each octal digit is three binary digits, and each hexadecimal digit
is four binary digits. Thus, to convert from binary to octal or hex,
just group the digits, and convert each group into an octal or hex digit.
To go the other way, convert each hex or octal digit into a set of bits.
Table 3
shows the conversions from each of the octal and hexadecimal single-digit
values to binary (with decimal digits thrown in for convenience):
Table 3: Binary, Octal and Hexadecimal Digit Conversion
Binary
Digits
|
Octal
Digit
|
Hexadecimal
Digit
|
Decimal
Digit
|
0000
|
0
|
0
|
0
|
0001
|
1
|
1
|
1
|
0010
|
2
|
2
|
2
|
0011
|
3
|
3
|
3
|
0100
|
4
|
4
|
4
|
0101
|
5
|
5
|
5
|
0110
|
6
|
6
|
6
|
0111
|
7
|
7
|
7
|
1000
|
|
8
|
8
|
1001
|
|
9
|
9
|
1010
|
|
A
|
|
1011
|
|
B
|
|
1100
|
|
C
|
|
1101
|
|
D
|
|
1110
|
|
E
|
|
1111
|
|
F
|
|
Lets look at some
specific examples using larger numbers:
- Binary to Octal: Suppose we start with
the binary number 110101001010. We divide this into groups of three:
(110)(101)(001)(010). Each of these, we convert to a number from 0 to
7 (which is easy to do in your head if you practice a bit). The result
is (6)(5)(1)(2) or 6512 octal.
- Hexadecimal to Binary: Let's start with
the hex number 0x4D1B. We convert each digit as given in the table above.
So, we have 0x4D1B = (0100)(1101)(0001)(1011) or 0100110100011011.
| If you find The TCP/IP Guide useful, please consider making a small Paypal donation to help the site, using one of the buttons below. You can also donate a custom amount using the far right button (not less than $1 please, or PayPal gets most/all of your money!) In lieu of a larger donation, you may wish to consider purchasing a download license of The TCP/IP Guide. Thanks for your support! |
|
|
Home -
Table Of Contents - Contact Us
The TCP/IP Guide (http://www.TCPIPGuide.com)
Version 3.0 - Version Date: September 20, 2005
© Copyright 2001-2005 Charles M. Kozierok. All Rights Reserved.
Not responsible for any loss resulting from the use of this site.
|