Minimum Range Values in the Include File LIMITS.H

Last reviewed: July 17, 1997
Article ID: 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


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 17, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.