Skip to content

Integers

Int

The int type is a 64-bit signed integer type.

You can declare ints by simply writing a number without a decimal point, or converting from a different type by using the int() function:

int myNum = 1
int myNum = int(1)

Uint

The uint type is a 64-bit unsigned integer. A uint can be declared similarly to an int, and the uint() function can be called to convert from a different type:

uint myNum = 1 // cannot be negative
uint myNum = 1u // can also use the `u` suffix
uint myNum = uint(1) // equivalent to the above expression

Warning

If a value exceeds the range of int or uint, the program will panic and crash.

If any of the integer conversion functions are used on a rational, then only the integer part will be returned. So, for example, int(2.5) will become 2.

Hexadecimal and Octal

Hexadecimal numbers need to be prefixed with 0x, for example, 0xFF. The part after the 0x is case-insensitive.

Octal numbers need to be prefixed with 0o, for example, 0o777.