Go to the first, previous, next, last section, table of contents.


11.1 Integer Types

C++ has four fundamental types to represent integers of different sizes: char, short, int, and long. For each of these types, there is a corresponding unsigned type to represent unsigned integer with the same number of bits as the plain (signed) type. It is required that unsigned integers obey the laws of arithmetic modulo 2^n, where n is the number of bits in the representation (see Section 3.6.1 of [Ellis-Stroustrup90]). However, the signed types have an infinite number of abstract values, most of which are not representable on a computer. One has to use range assertions (e.g., inRange or comparisons to such limits as INT_MIN and INT_MAX) if one wishes to ensure that the abstract value is representable.

In this section we describe the abstract values of C++ integer types, by giving the traits used to model them in Larch/C++. The common foundation for the various integer traits is the trait Integer found in the LSL Handbook (Appendix A of [Guttag-Horning93]). This trait defines unbounded integers with usual integer operations (+, -, *, div, mod, etc.).

See section 4.13 Literals for the syntax of literals that denote abstract values of the sorts specified here.


Go to the first, previous, next, last section, table of contents.