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.
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:
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
Supppose that we group the binary digits into fours. Then we might write
Then this might be written 958710 = (|0010|0101|0111|0011|)2
Now the groups of four can be given different symbols. There are 16 different
combinations of four binary digits. The symbols chosen are the common numerals
plus the letters a,b,c,d,e,f. The letters may be either upper or lower
case. The symbol table is
With this notation, the number would be represented as 958710
= 257316 This is called the hexadecimal representation.
In IDL the number would be represented as '2573'X. To denote a byte or
long integer one would use the notation '2573'XB or '2573'XL. The largest
possible byte value is 'FF'XB. The largest possible integer is '7FFF'X.
The largest possible long integer is '7FFFFFFF'X. Can you explain why?