Digital Circuits/Binary Systems

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Binary Numbers[edit]

Decimal Binary Octal

(base 8)

Hexadecimal

(base 16)

00 0000 00 0
01 0001 01 1
02 0010 02 2
03 0011 03 3
04 0100 04 4
05 0101 05 5
06 0110 06 6
07 0111 07 7
08 1000 10 8
09 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F

In order to convert from decimals to binary number, you must think in powers of 2. 1111= 15= 2 power 3 + 2 power 2+ 2 power 1 + 2 power 0 = 8+4+2+1=15. 2 power 5 = 32. to represent 31 in binary = 11111= 2 power 4 plus 15 as described above. Remember, the first digit is 2 power zero, which equals to one.

Number Base Conversions[edit]

as par role

Octal and Hexadecimal Numbers[edit]

Binary is the intrinsic number system of digital circuits, but long strings of 1s and 0s are not easy for humans to read and write. Therefore, number systems with easy conversion to and from binary were developed, including octal and hexadecimal.

The octal number system is base 8, in contrast to our native number system (decimal) which is base 10. In base 8, only the numbers 0 through 7 are used. Each octal digit can be represented by three binary bits, as shown in the conversion table above (under Binary Numbers).

Conversion between octal and binary is straightforward. To convert from octal to binary, convert each octal digit to its three-bit equivalent, and vice versa.

Similarly, the hexadecimal number system, base 16, facilitates easy conversion to and from binary. Each hexadecimal digit represents exactly four binary bits, as shown in the table above.

Note that in hexadecimal, the letters A through F are used to represent the decimal equivalent of 10 through 15, respectively.

Long strings of bits can be represented in a much more compact fashion using octal and hexadecimal. Of the two, hexadecimal is more commonly used. As each hexadecimal digit represents four bits, hexadecimal is well-suited to represent values likely to be found in modern systems (16, 32 or 64 bits). Hexadecimal values are often prefixed with the expression "0x" - for instance, 0xFF is the hexadecimal equivalent of 255.

Complements[edit]

The one's complement is computed by taking the given number, written in binary, and then "flipping" each bit, such that every 0 in the original is now represented as 1 in the one's complement, and every 1 in the original is represented as 0. This is an old system, and for all practical purposes, can be disregarded as no longer in use.

The two's complement for an N-bit integer is defined as a number which, when added to the number, gives 2N. The two's complement serves the purpose of representing signed integers; that is, the negative of a number is represented as the two's complement of the original. This means that the minimum number that can be represented by N bits is -2N-1, while the maximum number is 2N-1-1

Examples[edit]

Example 1[edit]

AB78 (hexadecimal) = 1010 1011 0111 1000 (binary) The one's complement of 0xAB78 is 0101 0100 1000 0111. The two's complement of 0xAB78 is 0101 0100 1000 1000.

Example 2[edit]

1F1F (hexadecimal)=0001 1111 0001 1111 (binary) The one's complement of 0x1F1F is 1110 0000 1110 0000. The two's complement of 0x1F1F is 1110 0000 1110 0001.

See also[edit]