ID Number: Q38026
5.10 6.00 6.00a 6.00ax 7.00 | 5.10 6.00 6.00a
MS-DOS | OS/2
Summary:
In Microsoft C versions 5.0, 5.1, 6.0, 6.0a, 6.0ax, and C/C++ version
7.0, the minimum value of CHAR and INT is off by one in the include
file LIMITS.H.
More Information:
This behavior occurs because there is no corresponding positive value
for the SIGNED CHAR's minimum value. For example, the range of a
SIGNED CHAR is -128 to 127. The range specified in LIMITS.H is -127 to
127. The range of a signed int is -32768 to 32767, but LIMITS.H
specifies the range as -32767 to 32767.
If you take the absolute value of -128 with the ABS() function, you
expect to get +128. This is correct; however, you must ensure that you
store the result in a variable that has a storage class that can
represent the value.
For example, it does not make sense, and is not possible, to take the
absolute value of -128 and to store it in a SIGNED CHAR. 127 is the
maximum positive value for this storage class.
The return value from the ABS() function is undefined if you store the
result in a storage class that cannot represent the value.
Additional reference words: 5.00 5.10 6.00 6.00a 6.00ax 7.00