GE6151 Computer Programming HEXADECIMAL NUMBERS

HEXADECIMAL NUMBERS

The hexadecimal number system has sixteen digits and is used primarily as a compact way of displaying or writing binary numbers because it is very easy to convert between binary and hexadecimal.Long binary numbers are difficult to read and write because it is easy to drop or transpose a bit. Hexadecimal is widely used in computer and microprocessor applications. The hexadecimal system has a base of sixteen; it is composed of 16 digits and alphabetic characters. The maximum 3-digits hexadecimal number is FFF or decimal 4095 and maximum 4-digit hexadecimal number is FFFF or decimal 65.535.

BINARY-TO-HEXADECIMAL CONVERSION

Simply break the binary number into 4-bit groups, starting at the right-most bit and replace each 4-bit group with the equivalent hexadecimal symbol as in the following example

Convert the binary number to hexadecimal: 1100101001010111

Solution:

1100 1010 0101 0111

C A 5 7 = CA57

HEXADECIMAL-TO-DECIMAL CONVERSION

One way to find the decimal equivalent of a hexadecimal number is to first convert the

hexadecimal number to binary and then convert from binary to decimal.

Convert the hexadecimal number 1C to decimal:

1 C

0001 1100= 24+ 2³ + 2² = 16 +8+4 = 28

DECIMAL-TO-HEXADECIMAL CONVERSION

Repeated division of a decimal number by 16 will produce the equivalent hexadecimal number,

formed by the remainders of the divisions. The first remainder produced is the least significant digit (LSD). Each successive division by 16 yields a remainder that becomes a digit in the equivalent hexadecimal number. When a quotient has a fractional part, the fractional part is multiplied by the divisor to get the remainder.

Convert the decimal number 650 to hexadecimal by repeated division by 16

40 /16= 2.5

0.5 x 16 = 8 =

8

2/16= 0.125

0.125 x 16 = 2 =

2 (MSD)

The hexadecimal number is 28A

   
650 /16 = 40.625

No comments:

Post a Comment