v2026.11.0
All Bundles
Bundle

Core runtime library providing primitive types (Bool, Byte, Char, Int, Float, String), the Ref wrappers and array helpers, and system utilities (console, files, threads, sockets). Collections are not here: they are in gen_collect.obl. Every Objeck program links against this bundle automatically via lang.obl.

Int

Integer class represents an operating system long value

Inherits: Number

Example

n := Int->Random(100);         # random 0–99
abs := Int->Abs(-42);          # 42
mx  := Int->Max(10, 20);       # 20
sorted := Int->Sort(v);        # sorted copy; ArraySort->Sort(v) sorts in place

Operations

Abs # function

Returns the absolute value

function : Abs() ~ Int

Return

TypeDescription
Intabsolute value

Example

Int->Abs(-99)->PrintLine();  # 99

Cbrt # function

Calculates the cube root

function : Cbrt() ~ Int

Return

TypeDescription
Intcube root value

Clamp # function

Returns a given value between an upper and lower bound

function : Clamp(min:Int, value:Int, max:Int) ~ Int

Parameters

NameTypeDescription
minIntminimal value
valueIntvalue between the min and max
maxIntmaximum value

Return

TypeDescription
Intmin if vaule is less than main, max if max is less than value, otherwise the value

Clear # function

Set all array elements to zero

function : Clear(a:Int[]) ~ Nil

Parameters

NameTypeDescription
aIntarray

Compare # native

Compares two values

function : native : Compare(l:Int, r:Int) ~ Int

Parameters

NameTypeDescription
lIntleft compare object
rIntright compare object

Return

TypeDescription
Int0 if equal, -1 if types differ, 1 if equal

CompareUnsigned # native

Compares two values as unsigned 64-bit quantities

function : native : CompareUnsigned(a:Int, b:Int) ~ Int

Parameters

NameTypeDescription
aIntfirst value
bIntsecond value

Return

TypeDescription
Int-1 if a is less than b, 0 if they are equal, 1 if a is greater

Copy # function

Copies elements between two integer arrays, or within one: overlapping ranges copy as if through a temporary array. Raises an IndexError, which a try/on or ?-> region can recover from, when a range does not fit its array; nothing is copied then.

function : Copy(dest:Int[], dest_offset:Int, src:Int[], src_offset:Int, count:Int) ~ Nil

Parameters

NameTypeDescription
destIntdestination array
dest_offsetIntfirst destination index
srcIntsource array
src_offsetIntfirst source index
countIntnumber of elements to copy; zero copies nothing

Example

a := [1, 2, 3, 4]
Int->Copy(a, 1, a, 0, 3);  # shifts the first three elements right by one

DivideUnsigned # native

Divides two values, treating both as unsigned 64-bit quantities

function : native : DivideUnsigned(a:Int, b:Int) ~ Int

Parameters

NameTypeDescription
aIntdividend
bIntdivisor

Return

TypeDescription
Intunsigned quotient

DoubleFactorial # native

Calculates the double factorial of the value

function : native : DoubleFactorial(n:Int) ~ Int

Parameters

NameTypeDescription
nIntnumber

Return

TypeDescription
Intdouble factorial of the value

Error # function

Prints error value

function : Error() ~ Nil

ErrorLine # function

Prints error value with newline

function : ErrorLine() ~ Nil

Factorial # native

Calculates the factorial of the value

function : native : Factorial(n:Int) ~ Int

Parameters

NameTypeDescription
nIntnumber

Return

TypeDescription
Intfactorial of the value

Fill # function

Sets every element of an array to a value

function : Fill(array:Int[], value:Int) ~ Nil

Parameters

NameTypeDescription
arrayIntarray
valueIntvalue

Fill # function

Sets a range of array elements to a value. Raises an IndexError, which a try/on or ?-> region can recover from, when the range does not fit the array; nothing is set then.

function : Fill(array:Int[], value:Int, offset:Int, count:Int) ~ Nil

Parameters

NameTypeDescription
arrayIntarray
valueIntvalue
offsetIntfirst index
countIntnumber of elements to set; zero sets nothing

Inf # function

Returns a positive infinity value

function : Inf() ~ Int

Return

TypeDescription
Intpositive infinity value

IsNeg # function

Checks is a number is negative

function : IsNeg() ~ Bool

Return

TypeDescription
Booltrue if negative, false otherwise

Max # native

Returns the largest integer value

function : native : Max(l:Int, r:Int) ~ Int

Parameters

NameTypeDescription
lIntvalue to compare
rIntvalue to compare

Return

TypeDescription
Intlargest integer value

Example

Int->Max(3, 7)->PrintLine();  # 7

MaxSize # function

Returns the maximum size of an integer

function : MaxSize() ~ Int

Return

TypeDescription
Intmaximum size of an integer

Min # native

Returns the smallest integer value

function : native : Min(l:Int, r:Int) ~ Int

Parameters

NameTypeDescription
lIntvalue to compare
rIntvalue to compare

Return

TypeDescription
Intsmallest integer value

Example

Int->Min(3, 7)->PrintLine();  # 3

MinSize # function

Returns the minimum size of an integer

function : MinSize() ~ Int

Return

TypeDescription
Intminimum size of an integer

ModUnsigned # native

Returns the remainder of dividing two values, treating both as unsigned 64-bit quantities

function : native : ModUnsigned(a:Int, b:Int) ~ Int

Parameters

NameTypeDescription
aIntdividend
bIntdivisor

Return

TypeDescription
Intunsigned remainder

NaN # function

Returns a NaN value

function : NaN() ~ Int

Return

TypeDescription
IntNaN value

NegInf # function

Returns a negative infinity value

function : NegInf() ~ Int

Return

TypeDescription
Intnegative infinity value

Pow # function

Calculates the power value

function : Pow(b:Int, r:Int) ~ Int

Parameters

NameTypeDescription
bIntpower base
rIntpower to raise

Return

TypeDescription
Intpseudo power value

Example

Int->Pow(2, 10)->PrintLine();  # 1024

Pow # function

Calculates the power value

function : Pow(b:Int, r:Float) ~ Float

Parameters

NameTypeDescription
bIntpower base
rFloatpower to raise

Return

TypeDescription
Floatpseudo power value

Print # function

Prints value

function : Print() ~ Nil

PrintLine # function

Prints value with newline

function : PrintLine() ~ Nil

PrintLine # native

Prints values

function : native : PrintLine(v:Int[]) ~ Nil

Parameters

NameTypeDescription
vIntvalues to print

PrintLine # native

Prints values

function : native : PrintLine(v:Int[,]) ~ Nil

Parameters

NameTypeDescription
vIntvalues to print

Random # function

Returns a pseudo random value between 0 and 1, inclusive

function : Random(range_start:Int, range_end:Int) ~ Int

Parameters

NameTypeDescription
range_startIntminimum value
range_endIntmaximum value

Return

TypeDescription
Intpseudo random value

Example

temp := Int->Random(-10, 40);
"Temp: {$temp}°C"->PrintLine();

Random # function

Returns a random number between 0 and max value, inclusive

function : Random(max:Int) ~ Int

Parameters

NameTypeDescription
maxIntmax value

Return

TypeDescription
Intrandom number within range

Example

dice := Int->Random(6) + 1;
"Rolled: {$dice}"->PrintLine();

ShiftRightUnsigned # native

Shifts a value right, treating it as an unsigned 64-bit quantity. Unlike '>>', zeros are shifted into the high bits rather than copies of the sign bit. This is what the '>>>' operator compiles to.

function : native : ShiftRightUnsigned(v:Int, count:Int) ~ Int

Parameters

NameTypeDescription
vIntvalue to shift
countIntnumber of bits to shift by, taken modulo 64 like every Int shift (count and 63): 0, 64 and -64 return the value unchanged, and -1 shifts by 63

Return

TypeDescription
Intshifted value

Sign # function

Returns the sign of a number

function : Sign() ~ Int

Return

TypeDescription
Intsign of a number

Sqrt # function

Calculates the square root

function : Sqrt() ~ Int

Return

TypeDescription
Intsquare root value

Example

Int->Sqrt(144)->PrintLine();  # 12

ToBinaryString # native

Returns the binary string value

function : native : ToBinaryString() ~ String

Return

TypeDescription
Stringbinary string value

ToByte # function

Returns the Byte value

function : ToByte() ~ Byte

Return

TypeDescription
Bytevalue

ToBytes # function

Returns the raw bytes of an array's values: 8 per value, little-endian, as they lie in memory. Byte->ToInts reads them back.

function : ToBytes(values:Int[]) ~ Byte[]

Parameters

NameTypeDescription
valuesIntvalues

Return

TypeDescription
Bytevalues->Size() * 8 bytes

ToBytes # function

Returns the raw bytes of a range of an array's values: 8 per value, little-endian. Raises an IndexError, which a try/on or ?-> region can recover from, when the range does not fit the array.

function : ToBytes(values:Int[], offset:Int, count:Int) ~ Byte[]

Parameters

NameTypeDescription
valuesIntvalues
offsetIntfirst value's index
countIntnumber of values

Return

TypeDescription
Bytecount * 8 bytes

Example

bytes := Int->ToBytes([1, 2, 3], 1, 2);  # 16 bytes

ToChar # function

Returns the Character value

function : ToChar() ~ Char

Return

TypeDescription
Charvalue

ToCommaString # native

Returns a comma formatted string value

function : native : ToCommaString() ~ String

Return

TypeDescription
Stringstring value

ToFloat # function

Returns the Float value

function : ToFloat() ~ Float

Return

TypeDescription
Floatvalue

ToHexDigits # function

Returns the value's hex digits without the 0x prefix, padded with zeros to a minimum width (ToHexString keeps the prefix)

function : ToHexDigits() ~ String

Return

TypeDescription
Stringlower-case hex digits, at least width of them

Example

255->ToHexDigits(4)->PrintLine(); # 00ff

ToHexString # native

Returns a hex string value

function : native : ToHexString() ~ String

Return

TypeDescription
Stringhex string value

ToHexString # native

Returns the values as a bracketed list of hex strings, each as ToHexString(Int) gives it

function : native : ToHexString() ~ String

Return

TypeDescription
Stringhex list, such as [0xff,0x10]; [] for an empty array

ToString # function

Returns the string value

function : ToString() ~ String

Return

TypeDescription
Stringstring value

Example

s := Int->ToString(255);
s->PrintLine();  # 255

ToString # native

Returns a string representation of the value

function : native : ToString() ~ String

Return

TypeDescription
Stringstring representation of the value

ToString # function

Returns a string representation of the int array

function : ToString(v:Int[,]) ~ String

Parameters

NameTypeDescription
vIntint array

Return

TypeDescription
Stringstring representation of the int array

ToUnsignedString # native

Returns the value formatted as an unsigned 64-bit decimal string. Negative values print as the large positive number their bits represent, so -1 becomes "18446744073709551615" rather than "-1".

function : native : ToUnsignedString(v:Int) ~ String

Parameters

NameTypeDescription
vIntvalue to format

Return

TypeDescription
Stringunsigned decimal string