Binary And Hexadecimal Numbers

A Binary Number System is a number system created with only two different symbols . The binary number system created with the digits 0 and 1 is very dominant in computer science and is considered the binary number system. In essence, any number system created with only two symbols is a binary number system.

A Hexadecimal Number System is a number system created with only sixteen symbols. The hexadecimal number system created with the decimal digits ( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ) and the first six letters of the alphabet ( a, b, c, d, e, f ) are also very dominant in computer science.

The binary and hexadecimal number systems are easily understood when the decimal number system is used as a frame of reference. This is because the key concepts of the decimal number system are also applicable in the binary and hexadecimal number systems. The first objective is to establish the counting numbers of the number system of interest relative to the decimal number system. In other words how do we express 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, in the binary number system? This objective is easy to realize once we understand that a unit in the binary number system is the same as a unit in the decimal number system and that only the digits 0 and 1 are used to compose the binary number system. The first ten numbers of the binary number system relative to the first ten numbers of the decimal number system are as follows:

Binary Numbers

However, this is usually not necessary because there is a simple conversion method that can be used to convert a decimal number to a binary number and a binary number to a decimal number. Each decimal number ≥ 1 can be obtained by multiplying the digits of the corresponding binary number by a power of 2 and summing the result . The power of 2 to use for a particular digit, equals the position number of the digit. Like decimal numbers, each digit in a binary number has a position number . The rightmost digit (assuming the number is a whole number) has a position number equal to 0 and the leftmost digit has a position number equal to n-1 (n is the number of digits in the number). For example, suppose we want to convert the binary number 1010 to a decimal number, we will carry out the conversion as follows:
(1) determine the position numbers of the digits of the number 1010
(2) multiply each digit with 2 raised to a power equal to their respective position number
(3) sum the result of the multiplication
So for our example we will have:
(1x23) + (0x22 + (1x21) + (0x20) = 8 +2 = 10.

The steps to convert an arbitrary decimal number c , to a binary number are as follows:
(1) Determine the maximum 2 n that is ≤ to c
If 2 n = c , the leftmost digit of the binary number is 1 and its position value equals n. Assign n zeroes to the remaining positions. For example, suppose c = 8, then 2 n= 2 3. Consequently, the binary equivalent of 8 is 1000.
(2) Calculate c - 2 n = y. Form the set A = { n-1, n-2...1, 0}.
(3) From A, select exponents to use to determine powers of 2 whose sum equals y
(4) For each such exponent, place the digit 1 in the position with the position value equal to the exponent.
(5) If there are open positions, place zeroes in them. The resulting string of 0 and 1 digits is the binary equivalent of the decimal number c.

Binary strings of 0 and 1 digits can be very long. The computer has no serious problem with lengthy binary numbers. But humans do. So in the computing space, hexadecimal numbers are used as compact representations of binary numbers. The decimal numbers 10, 11, 12, 13, 14, 15 are equivalent to the hexadecimal numbers a, b, c, d, e, f and the binary numbers 1010, 1011, 1100, 1101, 1110, 1111 respectively.

Now, it turns out that we can easily convert a lengthy binary number to a compact hexadecimal number when we group the digits of the binary number into 4s while still keeping their respective position values. We just replace each group of 4 with its hexadecimal equivalent. For example, 3d6e33be3ac5f is the hexadecimal number of the binary number 00111101011011110001100111011111000111010110001011111. The binary digits are sequentially grouped into 4s and then each group is replaced with their equivalent hexdecimal numbers. Note that when working with four digit hexadecimal numbers, 0 is 0000, 1 is 0001, 2 is 0010 and so on up until 7. In other words, if the hexadecimal digits are less than four, prepend zeroes.

Peter Oye Sagay

© 2000-2016 | All rights reserved.