Chapter: Basic Electrical and electronics : Digital Electronics

Hexadecimal Numbers

In addition to binary, another number base that is commonly used in digital systems is base 16. This number system is called hexadecimal, and each digit position represents a power of 16.

Hexadecimal Numbers

 

In addition to binary, another number base that is commonly used in digital systems is base 16. This number system is called hexadecimal, and each digit position represents a power of 16. For any number base greater than ten, a problem occurs because there are more than ten symbols needed to represent the numerals for that number base. It is customary in these cases to use the ten decimal numerals followed by the letters of the alphabet beginning with A to provide the needed numerals. Since the hexadecimal system is base 16, there are sixteen numerals required. The following are the hexadecimal numerals:

 

 

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

 

The following are some examples of hexadecimal numbers:

 

1016  4716  3FA16 A03F16

 

The reason for the common use of hexadecimal numbers is the relationship between the numbers 2 and 16. Sixteen is a power of 2 (16 = 24). Because of this relationship, four digits in a binary number can be represented with a single hexadecimal digit. This makes conversion between binary and hexadecimal numbers very easy, and hexadecimal can be used to write large binary numbers with much fewer digits. When working with large digital systems, such as computers, it is common to find binary numbers with 8, 16 and even 32 digits. Writing a 16 or 32 bit binary number would be quite tedious and error prone. By using hexadecimal, the numbers can be written with fewer digits and much less likelihood of error.

 

To convert a binary number to hexadecimal, divide it into groups of four digits starting with the rightmost digit. If the number of digits isn’t a multiple of 4, prefix the number with 0’s so that each group contains 4 digits. For each four digit group, convert the 4 bit binary number into an equivalent hexadecimal digit. (See the Binary, BCD, and Hexadecimal Number Tables at the end of this document for the correspondence between 4 bit binary patterns and hexadecimal digits) 


2. Convert the binary number 10110101 to a hexadecimal number


To convert a hexadecimal number to a binary number, convert each hexadecimal digit into a group of 4 binary digits.

 

4.  Convert the hex number 374F into binary


 

There are several ways in common use to specify that a given number is in hexadecimal representation rather than some other radix. In cases where the context makes it absolutely clear that numbers are represented in hexadecimal, no indicator is used. In much written material where the context doesn’t make it clear what the radix is, the numeric subscript 16 following the hexadecimal number is used. In most programming languages, this method isn’t really feasible, so there are several conventions used depending on the language. In the C and C++ languages, hexadecimal constants are represented with a ‘0x’ preceding the number, as in: 0x317F, or 0x1234, or 0xAF. In assembler programming languages that follow the Intel style, a hexadecimal constant begins with a numeric character (so that the assembler can distinguish it from a variable name), a leading ‘0’ being used if necessary. The letter ‘h’ is then suffixed onto the number to inform the assembler that it is a hexadecimal constant. In Intel style assembler format: 371Fh and

 

0FABCh are valid hexadecimal constants. Note that: A37h isn’t a valid hexadecimal constant. It doesn’t begin with a numeric character, and so will be taken by the assembler as a variable name. In assembler programming languages that follow the Motorola style, hexadecimal constants begin with a ‘$’ character. So in this case: $371F or $FABC or $01 are valid hexadecimal constants.

 


Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
Basic Electrical and electronics : Digital Electronics : Hexadecimal Numbers |


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.