Skip to main content
Version: 1.3.0

Declaring

In LIGO, there are two types of numbers: integers and natural numbers.

  • Integer literals are the same found in mainstream programming languages, for example, 10, -6 and 0, but there is only one canonical zero: 0 (so, for instance, -0 and 00 are invalid).

  • Natural numbers are written as digits followed by the suffix n, like so: 12n, 0n, and the same restriction on zero as integers applies: 0n is the only way to specify the natural zero.

Contrary to integral numbers in other programming languages, numbers in LIGO have arbitrary-precision, that is, they do not overflow or underflow. (See Tezos-specific features for more).

Digits of large numbers can be separated by an underscore, to increase readability.

// The following are integers
const zero = 0
const million = 1_000_000 // Grouping in French
const baekman = 100_0000 // Grouping in Korean
// The following are natural numbers
const zero_nat = 0n
const million_nat = 1_000_000n
const baekman_nat = 100_0000n

As a form of documentation, a type can be ascribed to each constant:

const zero : int = 0
const million : int = 1_000_000
const baekman : int = 100_0000
const zero_nat : nat = 0n
const million_nat : nat = 1_000_000n
const baekman_nat : nat = 100_0000n