The hexadecimal numeral system uses base 16 and includes the digits 0-9 and the letters A-F. It is useful for representing binary numbers more compactly, as each hexadecimal digit represents 4 binary digits. To convert between binary, hexadecimal, and decimal, the values are grouped into 4-bit sections for hexadecimal or 3-bit sections for octal and then converted according to place value tables.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online from Scribd
The hexadecimal numeral system uses base 16 and includes the digits 0-9 and the letters A-F. It is useful for representing binary numbers more compactly, as each hexadecimal digit represents 4 binary digits. To convert between binary, hexadecimal, and decimal, the values are grouped into 4-bit sections for hexadecimal or 3-bit sections for octal and then converted according to place value tables.
The hexadecimal numeral system uses base 16 and includes the digits 0-9 and the letters A-F. It is useful for representing binary numbers more compactly, as each hexadecimal digit represents 4 binary digits. To convert between binary, hexadecimal, and decimal, the values are grouped into 4-bit sections for hexadecimal or 3-bit sections for octal and then converted according to place value tables.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online from Scribd
The hexadecimal numeral system uses base 16 and includes the digits 0-9 and the letters A-F. It is useful for representing binary numbers more compactly, as each hexadecimal digit represents 4 binary digits. To convert between binary, hexadecimal, and decimal, the values are grouped into 4-bit sections for hexadecimal or 3-bit sections for octal and then converted according to place value tables.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online from Scribd
Download as docx, pdf, or txt
You are on page 1of 6
Hexadecimal Number System
1he Hexadecimal Number Base System
A big problem with the binary system is erbosity. 1o represent the alue 202 requires eight binary digits. 1he decimal ersion requires only three decimal digits and, thus, represents numbers much more compactly than does the binary numbering system. 1his act was not lost on the engineers who designed binary computer systems. \hen dealing with large alues, binary numbers quickly become too unwieldy. 1he hexadecimal ,base 16, numbering system soles these problems. lexadecimal numbers oer the two eatures: hex numbers are ery compact it is easy to conert rom hex to binary and binary to hex. Since we'll oten need to enter hexadecimal numbers into the computer system, we'll need a dierent mechanism or representing hexadecimal numbers since you cannot enter a subscript to denote the radix o the associated alue.
1he lexadecimal system is based on the binary system using a Nibble or 4-bit boundary. In Assembly Language programming, most assemblers require the irst digit o a hexadecimal number to be 0, and we place an l at the end o the number to denote the number base.
1he lexadecimal Number System: uses base 16 includes only the digits 0 through 9 and the letters A, B, C, D, L, and l
1his table proides all the inormation you'll eer need to conert rom one number base into any other number base or the decimal alues rom 0 to 16.
1o conert a hexadecimal number into a binary number, simply brake the binary number into 4-bit groups beginning with the LSB and substitute the corresponding our bits in binary or each hexadecimal digit in the number.
lor example, to conert 0ABCDh into a binary alue, simply conert each hexadecimal digit according to the table aboe. 1he binary equialent is:
0ABCDl ~ 0000 1010 1011 1100 1101
1o conert a binary number into hexadecimal ormat is almost as easy. 1he irst step is to pad the binary number with leading zeros to make sure that the the binary number contains multiples o our bits. lor example, gien the binary number 10 1100 1010, the irst step would be to add two bits in the MSB position so that it contains 12 bits. 1he reised binary alue is 0010 1100 1010.
1he next step is to separate the binary alue into groups o our bits, e.g., 0010 1100 1010. linally, look up these binary alues in the table aboe and substitute the appropriate hexadecimal digits, e.g., 2CA.
1he weighted alues or each position is as ollows: 16`3 16`2 16`1 16`0 4096 256 16 1
Binary to Hex Conversion
It is easy to conert rom an integer binary number to hex. 1his is accomplished by: Break the binary number into 4-bit sections rom the LSB to the MSB. Conert the 4-bit binary number to its lex equialent.
lor example, the binary alue 1010111110110010 will be written: 1010 1111 1011 0010 A l B 2
Hex to Binary Conversion
It is also easy to conert rom an integer hex number to binary. 1his is accomplished by: Conert the lex number to its 4-bit binary equialent. Combine the 4-bit sections by remoing the spaces.
lor example, the hex alue 0AlB2 will be written: A l B 2 1010 1111 1011 0010
1his yields the binary number 1010111110110010 or 1010 1111 1011 0010 in our more readable ormat. lex to Decimal Conersion
1o conert rom lex to Decimal, multiply the alue in each position by its hex weight and add each alue. Using the alue rom the preious example, 0AlB2l, we would expect to obtain the decimal alue 4498. A16`3 l16`2 B16`1 216`0 104096 15256 1116 21 40960 3840 16 2
40960 - 3840 - 16 - 2 ~ 4498
ecimal to Hex Conversion
1o conert decimal to hex is slightly more diicult. 1he typical method to conert rom decimal to hex is repeated diision by 16. \hile we may also use repeated subtraction by the weighted position alue, it is more diicult or large decimal numbers. Repeated Diision By 16
lor this method, diide the decimal number by 16, and write the remainder on the side as the least signiicant digit. 1his process is continued by diiding the quotient by 16 and writing the remainder until the quotient is 0. \hen perorming the diision, the remainders which will represent the hex equialent o the decimal number are written beginning at the least signiicant digit ,right, and each new digit is written to the next more signiicant digit ,the let, o the preious digit. Consider the number 4498.
As you can see, we are back with the original number. 1hat is what we should expect.
\hen you use hex numbers in an 8085 program, the Assembler usually requires the most signiicant hex digit to be 0 een i this number o digits exceed the size o the register. 1his is an Assembler requirement and your alue will be assembled correctly.
Hexadecimal numeral system lrom \ikipedia, the ree encyclopedia 1he hexadecimal numeral system, also known as just hex, is a numeral system made up o 16 symbols ,base 16,. It uses the common symbols in the decimal numeral system ,0 through 9, and includes six extra symbols. 1hese symbols are characters taken rom the Lnglish alphabet: A, B, C, D, L and l. 1he hexadecimal system replaced the octal numeral system or much o the work done on computers. 1he most commonly used orm o binary is the byte. 1his is eight binary digits ,bits,. lexadecimal only needs two digits to show the inormation in one byte o data. As computers become more adanced, they tend to use larger groups o bits but they use multiples o 8 ,16, 24, 32, 64, etc,. lexadecimal makes it easier to write these large binary numbers. lexadecimal numbers are written with a "h" ater the number. lor example, 63h means 63 hexadecimal. lexadecimal alues lexadecimal is similar to the octal numeral system ,base 8, because each can be easily compared to the binary numeral system. lexadecimal uses a our-bit binary coding. 1his means that eachdigit in hexadecimal is the same as our digits in binary. Octal uses a three-bit binary system.
Conersion Binary to hexadecimal Changing a number rom binary to hex uses a grouping method. 1he binary number is separated into groups o our digits starting rom the right. 1hese groups are then conerted to hexadecimal digits as shown in the chart aboe or the hexadecimal numbers 0 through l. 1o change rom hexadecimal, the reerse is done. 1he hex digits are each changed to binary and the grouping is usually remoed. Binary Groupings Hex 01100101
0110 0101 65 010010110110
0100 1011 0110 4B6 1101011101011010 1101 0111 0101 1010 D5A Hexadecimal and decimal 1o conert a number rom hexadecimal to decimal, do the ollowing: 1, 1ake the least signiicant hexadecimal digit. 1hat is the digit on the right end. I it is 0 thru 9 leae it at that alue. I it is A or aboe conert it to 10 thru 15. 1his will be the irst item in a sum. 2, 1ake the second-least signiicant digit. 1hat is next to the digit on the right end. Do the aboe but multiply the alue obtained by 16. Add this to the sum. 3, 1ake the third-least signiicant digit and conert is as in 1, aboe, then multiply it by 16 2 ,that is, 16 squared, or 256,. Add it to the sum. 4, Repeat the aboe or more places. lor each new place, add one more to the power o 16. Because hexadecimal uses extra symbols, it is important to remember the decimal alue o each o the symbols: A ~ 10, B ~ 11, C ~ 12, D ~ 13, L ~ 14, and l ~ 15.