A literal notation for an
Integer literal may be written in a variety of ways.
Integer one = 1; variable Integer oneMillion = 1000000; oneMillion = 1_000_000; oneMillion = 1M;
At its simplest, an
Integer literal is just a series of decimal digits,
9. Other digit characters
(digits from other scripts) are not allowed.
When a negative number is required, the unary minus operator may be used, like this:
Integer minusTwo = -2;
Integer literals with a leading zero,
0, are allowed, but unlike other
C-like programming languages, such literals are not interpreted using
To make long integer literals easier to read, groups of three digits may be
separated with an underscore,
_, similar to how a comma or stop is used
as a thousands separator in many written numbers. Only the left-most group
may have one or two digits.
Use of one of the following metric magnitudes as a suffix is supported:
Integer oneThousand = 1k;
A binary integer can be written with a
$ prefix, and again
_ may be
used to group digits, but binary digit groups are of length 4.
Integer eight = $1001; // binary literal
A hexadecimal integer can be written with a
# prefix, and again
may be used to group digits, but hexadecimal digit groups are of length
2 or 4.
Integer red = #ff_00_00; // hex literal
As a primary
Invoking members of the class
Integer directly on a literal is permitted:
Integer minusFive = 5.negativeValue;