Microsoft KB Archive/38026

{|
 * width="100%"|

Minimum Range Values in the Include File LIMITS.H

 * }

Q38026

5.10 6.00 6.00a 6.00ax 7.00 | 5.10 6.00 6.00a | 1.00 1.50 MS-DOS | OS/2 | WINDOWS kbtool kbfasttip -- The information in this article applies to: - Microsoft C for MS-DOS, versions 5.1, 6.0, 6.0a, and 6.0ax - Microsoft C for OS/2, versions 5.1, 6.0, and 6.0a - Microsoft C/C++ for MS-DOS, version 7.0 - Microsoft Visual C++ for Windows, versions 1.0 and 1.5 -- The values of SCHAR_MIN, SHRT_MIN, and INT_MIN are off by one in the include file LIMITS.H. For example, even though a signed char can be used to represent values in the range of -128 to 127, LIMITS.H defines SCHAR_MIN, the minimum signed char value, as -127. This is done for ANSI conformance. Section 2.2.4.2.1 of the ANSI specification for the C programming language specifies the minimum values for these integral types. The minimum values chosen were selected to accommodate compiler implementations, which use one's complement or sign-magnitude as well those implementations that use two's complement. The values for SCHAR_MIN, SHRT_MIN, and INT_MIN in the file LIMITS.H supplied with Visual C++ 32-bit Edition, are not off by one. For example, the value of SCHAR_MIN is -128. This allows access to the full range of values that can be represented by the type. This implementation is still ANSI-compliant because section 2.2.4.2.1 of the ANSI specification outlines the following when discussing the sizes of the integral types specified in LIMITS.H: ... Their implementation defined values shall be equal or greater in magnitude (absolute value) to those shown, with the same sign. Additional reference words: kbinf 1.00 1.50 5.10 6.00 6.00a 6.00ax 7.00 KBCategory: kbtool kbfasttip KBSubcategory: TlsMisc

Keywords : kb16bitonly

Issue type :

Technology : kbVCsearch kbAudDeveloper kbPTProdChange kbvc150 kbvc100 kbCCompSearch kbZNotKeyword3 kbCComp510DOS kbCComp600DOS kbCComp600aDOS kbCComp600axDOS kbCComp510OS2 kbCComp600OS2 kbCComp600aOS2 kbCVC700DOS