11.2.Β IntegersπŸ”—

Planned Content
  • Compile-time and run-time characteristics, and how they're inherited from Nat

  • API reference

Tracked at issue #104

πŸ”—inductive type
Int : Type

The type of integers. It is defined as an inductive type based on the natural number type Nat featuring two constructors: "a natural number is an integer", and "the negation of a successor of a natural number is an integer". The former represents integers between 0 (inclusive) and ∞, and the latter integers between -∞ and -1 (inclusive).

This type is special-cased by the compiler. The runtime has a special representation for Int which stores "small" signed numbers directly, and larger numbers use an arbitrary precision "bignum" library (usually GMP). A "small number" is an integer that can be encoded with 63 bits (31 bits on 32-bits architectures).

Constructors

  • ofNat : Nat β†’ Int

    A natural number is an integer (0 to ∞).

  • negSucc : Nat β†’ Int

    The negation of the successor of a natural number is an integer (-1 to -∞).