## Octal and Hexadecimal Data Types

Octal and hexadecimal data types are integer types that are available in most computer languages. They provide a convenient notation for the construction of integer values in the binary number system. All integer values are expressed in computer memory by setting the values of binary digits. However, long binary digit sequences are difficult for us to deal with.

Suppose that we wanted to write out the binary form of a number such as the decimal 9587. We would find that 958710 = (10010101110011)2 The expression could be made somewhat more readable by grouping the digits.

#### Octal Representation

Suppose that we group them into threes. Then this might be written 958710 = (|010|010|101|110|011)2 where the | is used as a divider between groups of three. A zero has been added to fill out the group on the left end. Each of the clusters of three digits can be compressed to a single symbol by using the symbols listed in the following table:

 Group 000 001 010 011 100 101 110 111 Symbol 0 1 2 3 4 5 6 7
Note that the symbols that are used to represent each group are the same as the integer value of each group. By using these symbols, the number can be expressed in a more compact form 958710 = (2|2|5|6|3). Because the symbols are the same as those that are used in base 8 counting, this is called octal notation. There is no need to maintain the partitions between the numbers. To make it clear that octal notation is used we can write 958710 = 225638

Computer notation does not easily handle subscripts. Hence, other notations have been invented. In IDL the notation for an octal number is "n or 'n'O. The number in our example would be written "22563 or '22563'O. The letters B or L can be used to indicate that a value is a byte or a long integer. "22563L or '22563'OL would be a long integer and "112B or '112'OB would be a byte. The largest possible byte integer is "377B. Can you explain why?