Programming
Comparison of Representations
Converting from either Hexadecimal, Binary or Octal to DecimalA binary, a hexadecimal or an octal number can be expressed as the sum of the successive powers of the base (either 2, 16, or 8, respectively), with the coefficients being the digits. For example,
Converting from Decimal to BinaryTo convert a decimal number into a binary number, divide it by 2 repeatedly and note the remainders. The remainders are the bits of the binary number. The last remainder is the most significant bit, and the first remainder is the least significant bit. For example,
Converting from Decimal to HexadecimalThere are two different ways to convert a decimal number into a hexadecimal number. 1. The first method is similar to converting a decimal to a binary and involves dividing the number by decimal 16 and noting the remainders. The first remainder is the least significant digit and the last remainder is the most significant digit. For example,
2. The second method involves converting the decimal number into a binary, then convert the binary into a hexadecimal number. To change the representation of the binary number to hexadecimal, separate the digits into 4-bit groups beginning with the least significant bit. Then write the hexadecimal equivalent of each group. For example,
Converting from Decimal to OctalTo convert a decimal number into an octal number, divide it by 8 repeatedly and note the remainders. The remainders are the digits of the octal number. The last remainder is the most significant digit, and the first remainder is the least significant digit. For example,
Converting between Binary and HexadecimalFrom Binary to Hexadecimal: To convert a binary number into its hexadecimal form, start by grouping the digits into 4-bit groups. Beginning with the least significant bit (all the way to the right of the number), write the hexadecimal equivalent of each group. For example,
From Hexadecimal to Binary: To convert a hexadecimal number into a binary, just reverse the above process; starting all the way to the right, convert each digit into a 4-bit binary number. Converting between Binary and OctalFrom Binary to Octal: To convert a binary number into its octal form, start by grouping the digits into 3-bit groups. Beginning with the least significant bit (all the way to the right of the number), write the octal equivalent of each group. For example,
From Octal to Binary: To convert an octal number into a binary, just reverse the above process; starting all the way to the right, convert each digit into a 3-bit binary number. Page author: Dawn Rorvik (rorvikd@evergreen.edu) Last modified: 05/20/2003 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||