Binary Numbers Tutorial
- Muhammad Shahid
- m_shahid@live.co.uk
- 12 min
- 468 Views
- 0 Comments
Binary Numbers Tutorial
The digital electronic circuits and computers use binary numbers in arithmetic operations, information transfer, data storage (memory), etc. As seen in previous articles, there are different numbering systems to represent the equivalent binary numbers. The usage of different binary numbers depends on the system architecture, memory size, application type, etc. However, adopting other numbering systems besides binary helps in reducing the number of digits and, as such, the number becomes more comfortable to read or write. The different numbering systems are used in different digital circuits to represent binary numbers. For example, a keyboard would use decimal numbers, whereas, the memory may use hexadecimal numbers.
The different numbering systems have been discussed previously in the articles. The four major forms of numbering systems are briefly reviewed below.
Binary
The binary numbering system uses a base-2 (MOD-2) system and, as such, has only two (2) numerals i.e. “0” and “1” to represent a binary digit (bit). The binary numbers are denoted by writing a subscript (2) e.g. 100110112. … read more
Octal
The octal numbering system has a base-8 (MOD-8) system and uses eight (8) numerals from “0” to “7” to represent an octal digit. The octal numbers are denoted by using a subscript (8) e.g. 4268. … read more
Decimal
The decimal numbering system uses a base-10 (MOD-10) system and, as such, has ten (10) numerals from “0” to “9” to represent a decimal digit. The decimal numbers are denoted by writing a subscript (10) e.g. 42610. However, a number without any specific identification or subscript is interpreted to be a decimal number. … read more
Hexadecimal
The hexadecimal numbering system has a base-16 (MOD-16) system and uses sixteen (10) numerals from “0” to “9” and six (6) alphabets from “A” to “F” to represent a hexadecimal digit. The hexadecimal numbers are denoted by using a subscript (16) e.g. 9AD216 or by a hash (#) sign e.g. #9AD2. … read more
In the following table, a comparison of the aforementioned numbering systems is given.
From the above comparison table, it is eminent that using a higher base value numbering significantly reduces the binary number representation length. The larger binary number, usually 16, 32, or 64-bits, are difficult to write and read by a human being specially in writing or debugging programs. The binary and decimals numbers are seldomly used in special cases. The octal and hexadecimal numbers are used commonly to represent binary numbers having bit lengths in multiples of eight (8) i.e. 8, 16, 24, or 32-bits, etc. The octal number splits the binary numbers into 3-bit groups and a 3-bit covers the whole range of octal numerals from “0” to “7”. Likewise, the hexadecimal number splits the binary number into groups of 4-bits and each group covers the whole range of hexadecimal numerals from “0” to “15” (“10” to “15” are represented by “A” to “F” alphabets, respectively).
The byte (8-bits) can be split into two 4-bit groups to form a hexadecimal number. The octal number requires an additional 9th bit in order to evenly split a byte into three 3-bit groups as a byte (8-bits) cannot be accommodated in two 3-bit groups. The byte (8-bit), word (16-bit), and double word (32-bit), etc. are easily split into 4-bit groups to form a hexadecimal number and, this makes, the best choice to represent larger binary numbers, memory addresses, registers, etc.
Conversion from Binary to Other Number Systems
The binary number is first converted to an equivalent decimal number by using a weighted sum of digits method. The equivalent decimal number is then converted to desired octal or hexadecimal number. Mathematically, the number is a weighted sum of digits and its general form is given below:
Using the above mathematical expression, any number (binary, octal, or hexadecimal) can be converted to an equivalent decimal number.
Proceeding, further, to convert a decimal number to an equivalent binary, octal, or hexadecimal, requires the application of repeated division by the relevant base value of the desired numbering system. The decimal number is repeatedly divided until the quotient becomes zero (0) and, at each step, the remainder is noted which forms the desired equivalent number in reverse order. In the following examples, a binary number is converted to other numbering systems. First, the binary number is converted to an equivalent decimal number and then, further, converted to the desired number.
Binary to Decimal Conversion Example
The binary number (110111102) is converted to a decimal number by the weighted sum of digits method as given below.
Binary to Octal Conversion Example
The above-converted decimal number (22210) is then further converted to an octal number by applying the repeated-division-by-8 method in order to obtain binary to octal conversion.
Binary to Hexadecimal Conversion Example
Likewise, in the method adopted above for converting to an octal number, the equivalent hexadecimal number is obtained by applying the repeated-division-by-16 method on the converted decimal number (22210).
Conversion from Other Number Systems to Binary
In the following sections, examples of converting a binary number to its equivalent decimal, octal, and hexadecimal are given.
Decimal to Binary Conversion Example
The conversion from decimal to equivalent binary number requires the application of the repeated-division-by-2 method. The decimal number (1910) is converted to an equivalent binary number by using this method which is given below.
Octal to Binary Conversion Example
The octal number’s equivalent in binary is found by combining the equivalent 3-bit binary numbers of each octal digit. The combination of equivalent 3-bit binary numbers of each octal digit forms the desired binary numbers. Hereunder, the octal number (6328) is converted to an equivalent binary number.
Hexadecimal to Binary Conversion Example
The conversion of a hexadecimal number to an equivalent binary number is straightforward. Each hexadecimal digit is converted to an equivalent 4-bit binary number and obtained 4-bit binary numbers are combined to form the desired converted binary number. The example below shows the conversion of the hexadecimal number (A3F16) to an equivalent binary number.
Conclusion
- The digital electronic circuits and computers use binary numbers for arithmetic operations, information transfer, storage (memory), etc. The binary numbers are converted to other numbering systems such as Octal, Decimal, or Hexadecimal which eases the handling of larger binary numbers.
- Digital data is most commonly represented in hexadecimal numbering systems. The hexadecimal number uses a 4-bit binary number to represent each digit which provides a range of fifteen (15) numerals from “0” to “15”. The numerals from “10” to “15” are represented by “A” to “F” alphabets, respectively.
- The conversion from binary to other numbering systems is achieved by first converting a binary number to an equivalent decimal number using the weighted-digit-sum method. The obtained decimal number is then further converted to the desired numbering system using the repeated-division method.
- The conversion from decimal to binary number requires the application of the repeated-division-by-2 method.
- The conversion from Octal or Hexadecimal number requires finding the equivalent 3-bit or 4-bit binary number for each digit, respectively. The found 3-bit or 4-bit binary numbers are combined to form desired converted binary number.