Main Page

Previous Page
Next Page

[Page 1243 (continued)]


  • An integer such as 19 or 227 or 63 in a C++ program is assumed to be in the decimal (base 10) number system. The digits in the decimal number system are 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9. The lowest digit is 0 and the highest is 9one less than the base of 10.

  • Internally, computers use the binary (base 2) number system. The binary number system has only two digits, namely 0 and 1. Its lowest digit is 0 and its highest is 1one less than the base of 2.

  • The octal number system (base 8) and the hexadecimal number system (base 16) are popular primarily because they make it convenient to abbreviate binary numbers.

  • The digits of the octal number system range from 0 to 7.

  • The hexadecimal number system poses a problem because it requires 16 digitsa lowest digit of 0 and a highest digit with a value equivalent to decimal 15 (one less than the base of 16). By convention, we use the letters A through F to represent the hexadecimal digits corresponding to decimal values 10 through 15.

  • Each number system uses positional notationeach position in which a digit is written has a different positional value.

  • A particularly important relationship of both the octal and the hexadecimal number systems to the binary system is that their bases (8 and 16 respectively) are powers of the base of the binary number system (base 2).

  • To convert an octal to a binary number, replace each octal digit with its three-digit binary equivalent.

  • To convert a hexadecimal to a binary number, simply replace each hexadecimal digit with its four-digit binary equivalent.

  • Because we are accustomed to working in decimal, it is convenient to convert a binary, octal or hexadecimal number to decimal to get a sense of the number's "real" worth.

  • To convert a number to decimal from another base, multiply the decimal equivalent of each digit by its positional value and sum the products.

  • Computers represent negative numbers using two's complement notation.

  • To form the negative of a value in binary, first form its one's complement by applying C++'s bitwise complement operator (~). This reverses the bits of the value. To form the two's complement of a value, simply add one to the value's one's complement.

Previous Page
Next Page