1.2 Internal Representation of Integers

BITLIB is a library for bit handling. Integers are generally used for bit handling. Thus, the problem is in how the integer is represented in bit string. Furthermore, in some cases, it may be more convenient to handle a bit string as a hexadecimal number rather than a decimal number. The HEXLIB library is available for this purpose.

There are two method of expressing a signed integer within a computer: the "absolute value representation" and the "complement representation." The "absolute value representation" expresses the absolute value of the integer in binary with a sign bit as the leading bit (0 when positive and 1 when negative). This method is simple and easy to understand. However, it has the setback that two representations exist for the integer 0, that is 0 and -0.

The "complement representation" is defined in a  slightly more complex manner, but it has been implemented in a majority of the computers.

It can be seen from the above that, in a complement representation, there is a one-to-one correspondence between a bit string in internal representation and its value as an integer. Thus, integer-type variables are used for handling data as bit strings and not as numbers.