Integer Type

The Integer type represents a signed 64-bit integer. It is the primary type for whole numbers in DWScript.

Literals

Integers can be defined in multiple formats. You can use underscores _ as digit separators to improve readability of large numbers. DWScript supports both type inference and explicit typing.

Format Prefix Example
Decimal (none) 1_000_000
Hexadecimal $ or 0x $FF or 0xFF
Binary % or 0b %1010 or 0b1010
// Type inference
var d := 123;
var h := $FF;       // 255
var b := %1010;     // 10
var big := 1_000_000;

// Explicit typing
var count : Integer := 10;
var status : Integer;
status := 200;

Operations

Standard arithmetic operators apply: +, -, *, div (integer division), and mod (remainder). Bitwise operators like shl, shr, and, or, xor, and not are also supported.

var x := 10 div 3; // 3
var y := 10 mod 3; // 1
var z := (1 shl 8); // 256

Conversions

You can convert integers to strings or other types using built-in functions or method helpers.

var i := 255;
var s := i.ToString;          // "255"
var hex := i.ToHexString(2);  // "FF"
var val := StrToInt('123');

Type Limits

You can retrieve the minimum and maximum possible values for the 64-bit Integer type using the Low and High functions.

var min := Low(Integer);
var max := High(Integer);

PrintLn(min.ToString);
PrintLn(max.ToString);
Result
-9223372036854775808
9223372036854775807

Related Reference

On this page