To convert a binary number to a hexadecimal number you must first understand what each digit in the binary number means. To explain this let's look at the decimal number 247.
The '2' in 247 represents two hundred because it is a two in the
hundreds position (two times a hundred is two hundred). In similar fashion, the '4' in 247 represents forty because it is a four in the tens position (four times ten is forty). Finally, the '7' represents seven because it is a seven in the units position (seven times one is seven). In a decimal number, the actual value represented by a digit in that number is determined by the numeral and the position of the numeral within the number.
It works the same way with a binary number. The right-most position in a binary number is units; moving to the left, the next position is twos; the next is fours; the next is eights; then sixteens; then thirty-twos ... Notice that these numbers are all powers of two - 2^0, 2^1, 2^2, 2^3, 2^4, 2^5. (The units, tens, hundreds, thousands, ten thousands of the decimal system are all powers of ten: 10^0, 10^1, 10^2, 10^3, 10^4).
So, to convert the binary number 1001 (don't read that as one thousand one - read it as one zero zero one) to decimal, you determine the actual value represented by each '1' and add them together. The right-most '1' has a decimal value of 1 (it is in the 2^0, or units, position) and the left-most '1' has a decimal value of 8 (it is in the 2^3, or eights, position). So the binary number 1001 is equal to decimal 9. Here's another way to look at it:
1 0 0 1
^ ^ ^ ^
| | | |_________> 1 x 2^0 = 1 x 1 = 1
| | |___________> 0 x 2^1 = 0 x 2 = 0
| |_____________> 0 x 2^2 = 0 x 4 = 0
|_______________> 1 x 2^3 = 1 x 8 = 8
---
9
Both the decimal system and the binary system are positional number systems. The hexadecimal system is another positional number system.
The binary system has only two numerals - 0 and 1; the decimal system has ten numerals: 0,1,2,3,4,5,6,7,8, and 9. In the hexadecimal (or hex) system there are sixteen numerals: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E, and F. Zero through nine have the same value as a decimal numeral, and A is ten, B is eleven, C is twelve, D is thirteen, E is fourteen, and F is fifteen. After a while you will get used to seeing "letters" used as numerals!
The decimal number system is also referred to as "base ten" since each position in a decimal number represents a power of ten - a number that can be written as 10^n, where n is an integer. The binary number system is also referred to as "base two" since each position in a binary number represents a power of two - a number that can be written as 2^n, where n is an integer. The hex number system is also referred to as "base sixteen" since each position in a hexadecimal number represents a power of sixteen - a number that can be written as 16^n, where n is an integer.
The right-most position in a hexadecimal number is units; moving to the left, the next position is sixteens; the next is two hundred fifty-sixes; the next is four thousand ninety-sixes, and so on - all powers of sixteen - 16^0, 16^1, 16^2, 16^3.
To convert a binary number to a hex equivalent, notice that four
binary digits together can have a value of from 0 to 15 (decimal)
exactly the range of one hex digit. So four binary digits will always
convert to one hex digit!
For example:
10110111 = B7 (hex)
The right-most four digits of the binary number (0111) equal seven, so the hex digit is '7'. The remaining left-most four digits of the binary number (1011) equal eleven, so the hex digit is 'B'. Here is another way of looking at it:
1 0 1 1 0 1 1 1 from right to left, make four-digit groups
\ /\ /
\ / \ /
eleven seven determine the decimal equivalent of each
| | group
V V
B 7 write the equivalent hexadecimal digit
What is the decimal equivalent of B7 hex?
B 7
^ ^
| |_________> 7 x 16^0 = 7 x 1 = 7
|___________> 11 x 16^1 = 11 x 16 = 176
---
183 decimal
Check that against the decimal equivalent of 10110111 binary:
1 0 1 1 0 1 1 1
^ ^ ^ ^ ^ ^ ^ ^
| | | | | | | |_________> 1 x 2^0 = 1 x 1 = 1
| | | | | | |___________> 1 x 2^1 = 1 x 2 = 2
| | | | | |_____________> 1 x 2^2 = 1 x 4 = 4
| | | | |_______________> 0 x 2^3 = 0 x 8 = 0
| | | |_________________> 1 x 2^4 = 1 x 16 = 16
| | |___________________> 1 x 2^5 = 1 x 32 = 32
| |_____________________> 0 x 2^6 = 0 x 64 = 0
|_______________________> 1 x 2^7 = 1 x 128 = 128
---
183 decimal
Hope this helps.
2006-12-29 03:47:56
·
answer #2
·
answered by phillylady4u 2
·
0⤊
0⤋
You need to know about 'number bases'.
The numbers we use every day are 'base 10'.
From right to left the digits represent 1's, 10's, 100's, 1000's, etc.
For example, in the number 258, each digit has 10 states, 0 to 9. If I incremented (added 1 to) the 8 it would go to 9. If I added another 1, I've exceded the maximum 9, I have to reset it to 0 and add 1 (representing a lump of 10) to the next digit left. The 5 increments to 6, giving 260.
Binary numbers are 'base 2' numbers, with only 2 states, 0 and 1. If you start at 0000 and start incrementing, it goes 0001, 0010, 0011, etc. Digits can never go to 2, they are limited to 0 and 1.
From right to left the digits represent 1's, 2's, 4's, 8's, etc.
Hexadecimal numbers are 'base 16' numbers. Each digit has 16 states, which are represented by values :-
0 1 2 3 4 5 6 7 8 9 A B C D E F
From right to left the digits represent 1's, 16's, 256's, etc.
To convert a binary number to Hexadecimal, take each group of 4 binary digits from right to left and convert to one Hex Digit
0000 = 0 Hex
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
If you look at D for example, you'll see that D (13 decimal), is made from 1101 binary, which is 1 lot of 8, 1 lot of 4, 0 lots of 2 and 1 lot of 1, added together. 8+4+1 = 13 decimal = D Hex.
2006-12-29 04:00:27
·
answer #3
·
answered by ricochet 5
·
0⤊
0⤋
binary to hex: group numbers by fours, then convert each four-group to decimal in your head, then convert that to hex:
ex. 100101101
split into fours, add leading zeros for the first four:
0001 0010 1101
0001 = 1 in decimal = 1 in hex
0010 = 2 in decimal = 2 in hex
1101 = 1 + 4 + 8 = 13 = D in hex
so the number is 12D
do the opposite for hex to binary: D = 13 = 8+4+1 = 1101, etc.
2006-12-29 03:47:06
·
answer #4
·
answered by mathu9 2
·
0⤊
0⤋