Courtesy of: thevbprogrammer.com

Number Systems

Number Systems Concepts

The study of number systems is useful to the student of computing due to the fact that number systems other than the familiar decimal (base 10) number system are used in the computer field. Digital computers internally use the binary (base 2) number system to represent data and perform arithmetic calculations. The binary number system is very efficient for computers, but not for humans. Representing even relatively small numbers with the binary system requires working with long strings of ones and zeroes. The hexadecimal (base 16) number system (often called "hex" for short) provides us with a shorthand method of working with binary numbers. One digit in hex corresponds to four binary digits (bits), so the internal representation of one byte can be represented either by eight binary digits or two hexadecimal digits. Less commonly used is the octal (base 8) number system, where one digit in octal corresponds to three binary digits (bits). In the event that a computer user (programmer, operator, end user, etc.) needs to examine a display of the internal representation of computer data (such a display is called a "dump"), viewing the data in a "shorthand" representation (such as hex or octal) is less tedious than viewing the data in binary representation. The binary, hexadecimal , and octal number systems will be looked at in the following pages. The decimal number system that we are all familiar with is a positional number system. The actual number of symbols used in a positional number system depends on its base (also called the radix). The highest numerical symbol always has a value of one less than the base. The decimal number system has a base of 10, so the numeral with the highest value is 9; the octal number system has a base of 8, so the numeral with the highest value is 7, the binary number system has a base of 2, so the numeral with the highest value is 1, etc. Any number can be represented by arranging symbols in specific positions. You know that in the decimal number system, the successive positions to the left of the decimal point represent units (ones), tens, hundreds, thousands, etc. Put another way, each position represents a specific power of base 10. For example, the decimal number 1,275 (written 1,27510)* can be expanded as follows: 1 2 7 510 5 7 2 1 x x x x 100 101 102 103 = = = = 5 7 2 1 x x x x 1 10 100 1000 = = = = 5 70 200 1000 -----1275

10

Remember the mathematical rule that n0 = 1, or any number raised to the zero power is equal to 1. Here is another example of an expanded decimal number: 1 0 4 0 610 6 0 4 0 1 x x x x x 100 101 102 103 104 = = = = = 6 0 4 0 1 x x x x x 1 10 100 1000 10000 = 6 = 0 = 400 = 0 = 10000 -------10406

10

* When doing number system problems, it is helpful to use a subscript to indicate the base of the number being worked with. Thus, the subscript "10" in 127510 indicates that we are working with the number 1275 in base 10. Page 2

Number Systems

TRY THIS: Expand the following decimal number: 5 1 3 010

The Binary Number System

The same principles of positional number systems we applied to the decimal number system can be applied to the binary number system. However, the base of the binary number system is two, so each position of the binary number represents a successive power of two. From right to left, the successive positions of the binary number are weighted 1, 2, 4, 8, 16, 32, 64, etc. A list of the first several powers of 2 follows: 20 = 1 26 = 64 21 = 2 27 = 128 22 = 4 28 = 256 23 = 8 29 = 512 24 = 16 210 = 1024 25 = 32 211 = 2048

For reference, the following table shows the decimal numbers 0 through 31 with their binary equivalents: Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Binary 0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111 Decimal 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Binary 10000 10001 10010 10011 10100...