Binary Numbering System
The binary or base-2 numbering system may be regarded as the 'natural' numbering system to use with digital computers, since the low or high logic levels used internally by digital circuits correspond directly with the 0 or 1 values of a binary number.
In the binary numbering system, each digit is worth twice as much as the digit immediately to its right and can take a value of either 1 or 0. A single binary digit is normally referred to as a bit (a contraction of BInary digiT).
The following table shows the counting sequence when a binary number is used to represent a sequence of positive integers.
|Binary Value||Decimal Value|
A disadvantage when reading or writing binary numbers is that long strings of ones and zeroes are difficult to read, hence direct use of the binary numbering system by humans is prone to error. This problem can be reduced somewhat if binary numbers are arranged in groups of four bits, starting at the right hand side. For example the binary number 0111 1101 1111 11102 is much easier to read than 01111101111111102.
Range of a Binary Number
As a general rule, the range of an N-bit integer number is 2N, or 0 to (2N−1). For example the range of an 8-bit number is 28 or 256 (0–255). The following table lists the most commonly encountered binary integer number types and their characteristics.
Terminology varies related to integer number types with 16 or more bits. The appropriate documentation should be studied to identify any implementation-specific terminology or conventions.
Converting between Binary and Decimal
Digital computers use the binary numbering system internally while humans prefer to count in the more familiar base-10. Thus it is useful to be able to convert numbers from one number base to another.
Converting from Binary to Decimal
Begin by writing the decimal value above each digit of the binary number, as shown in the example below.
Next, add together the values of those digits which are non-zero. Hence, for the example shown, it can be seen that 1 01112 is equivalent to 2310.
Converting from Decimal to Binary
There are two commonly used manual methods. See which you prefer.
Identify the largest power of two (1,2,4, etc.) which is less than or equal to the original base-10 number. Set this bit to one in the binary number. Now subtract this power of two from the original number, leaving a remainder. Repeat this process until there is no remainder. The following example converts the decimal number 8510 to binary, giving a result of 101 01012.
This second technique uses repeated division by two, with the remainders at each stage forming the binary number. The repeated division continues until the quotient becomes zero. The example below converts a decimal value of 15510 to binary, giving a result of 1001 10112
See the Numbering Systems Problems page for additional practice activities. Windows users may check their results by using the Windows Calculator in programmer's view.