Literals

Literal Expressions, or simply Literals, are constant values expressed directly in code by providing a concrete, hardcoded number or string value.

Integer Literals

The default type of an Integer Literal is determined by the first type from the following list that can hold the number: Int32, UInt32, Int64, UInt64 and BigInteger (the latter currently limited to the .NET platform).

Integer Literals are supported as decimal (default) or as hexadecimal and binary (with $ and % prefixes, respectively). Spaces are allowed within the number to logically group digits, commonly in blocks of 3 for decimal, 4 for hexadecimal and 8 for binary.

var MyInteger := 153; // Decimal (Base 10) integer literal
var MyHexInteger := $100; // Hexadecimal (Base 16) integer literal with a value 256
var MyBinaryInteger := %101; // Binary (Base 2) integer literal with a value of 5
var MyBigInteger := 698574357436578436543275894375984326598342759435634977653476574392865784356;
var MySpacedInteger := 500 000;
var MySpacedHexInteger := $c000 0000;

Floating Point Literals

Floating Point Literals can be defined by including a decimal point in the literal, or by using exponential notation with the letter E (upper or lower case). Note that floating point literals only accept decimal numbers, not hexadecimal or binary.

var MyFloat := 153.0;
var MySecondInteger := 123E3; // 123000.0

Boolean Literals

The true and false keywords can be used to express Boolean literal values.

var oxygeneRocks = true;
var oxygeneIsCaseSensitive = false;

Nil Pointer Literals

The nil keyword can be used to express a nil pointer, reference type or a nullable type without value.

var b := nullable Boolean := nil;