Previous: Booleans, Up: Built-in datatypes


7.1.2 Integers

The int type can take an optional width parameter that specifies the physical number of bits used to represent the integer. An integer value need not necessarily be encoded in two's-complement; one may use more bits to encode more abstract values (like “not-an-number”), or employ error-correcting codes. The default width of an int is 321. Technically speaking, int is a built-in templated (parameterized) datatype definition. Templates are discussed in more detail in Templates. The specify an int's width, one can write int<pint>.

For integer type-checking in the nonmeta language, the assignment of a pint value or constant to an int of any width is legal. Implementation detail: this is accomplished by using int<0> as a magic width type for meta-valued integers and constants.

Arithmetic and relational operators: In CHP, the standard arithmetic operations on int types interprets the bits as signed two's-complement integers. Operator overloading is not yet supported for user-defined datatypes, but may be in the future.

Update: int<1> is equivalent to bool in a data type context.


Footnotes

[1] 32 was chosen arbitrarily.