v2026.11.3
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.

Byte

The byte class represents a 1-byte value.

Inherits: Number

Operations

Abs # function

Returns the absolute value

function : Abs() ~ Byte

Return

TypeDescription
Byteabsolute value

CRC32 # function

Calculates the signed CRC32 value for the stream

function : CRC32() ~ Int

Return

TypeDescription
Intsigned CRC32

Clamp # function

Returns a given value between an upper and lower bound

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

Parameters

NameTypeDescription
minByteminimal value
valueBytevalue between the min and max
maxBytemaximum value

Return

TypeDescription
Bytemin 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(b:Byte[]) ~ Nil

Parameters

NameTypeDescription
bBytebyte array

Compare # native

Compares two values

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

Parameters

NameTypeDescription
lByteleft compare object
rByteright compare object

Return

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

CompressDeflate # function

Compresses a byte stream as raw deflate (RFC 1951): the compressed blocks alone, with no zlib header or checksum (CompressZlib) and no gzip framing (CompressGzip). This is the format of zip members and of zlib/Python with windowBits -15. It is not Brotli, and not HTTP's "deflate" content coding, which is the zlib format.

function : CompressDeflate() ~ Byte[]

Return

TypeDescription
Bytecompressed bytes

CompressGzip # function

Compresses a byte stream using gzip

function : CompressGzip() ~ Byte[]

Return

TypeDescription
Bytecompressed bytes

CompressZlib # function

Compresses a byte stream using zlib

function : CompressZlib() ~ Byte[]

Return

TypeDescription
Bytecompressed bytes

CompressZlib # function

Compresses a byte stream using zlib at a given level: 1 is fastest, 9 smallest (what CompressZlib(input) uses), 0 stores without compressing, and -1, or any value out of range, is zlib's default (6). UncompressZlib reads every level.

function : CompressZlib(input:Byte[], level:Int) ~ Byte[]

Parameters

NameTypeDescription
inputBytebytes to compress
levelIntcompression level, -1 to 9

Return

TypeDescription
Bytecompressed bytes

Copy # function

Copies elements between two bytes 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:Byte[], dest_offset:Int, src:Byte[], src_offset:Int, count:Int) ~ Nil

Parameters

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

Example

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

Error # function

Prints error value

function : Error() ~ Nil

ErrorLine # function

Prints error value with newline

function : ErrorLine() ~ Nil

Fill # function

Sets every element of an array to a value

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

Parameters

NameTypeDescription
arrayBytearray
valueBytevalue

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:Byte[], value:Byte, offset:Int, count:Int) ~ Nil

Parameters

NameTypeDescription
arrayBytearray
valueBytevalue
offsetIntfirst index
countIntnumber of elements to set; zero sets nothing

Find # native

Searches for the first occurrence of a byte

function : native : Find(bytes:Byte[], search:Byte) ~ Int

Parameters

NameTypeDescription
bytesBytebyte array to search
searchBytebyte to search for

Return

TypeDescription
Inttrue of found, false otherwise

Find # native

Searches for the first occurrence of a byte

function : native : Find(bytes:Byte[], offset:Int, search:Byte) ~ Int

Parameters

NameTypeDescription
bytesBytebyte array to search
offsetIntsearch offset
searchBytebyte to search for

Return

TypeDescription
Inttrue of found, false otherwise

Find # native

Searches for the first occurrence of a byte array

function : native : Find(bytes:Byte[], search:Byte[]) ~ Int

Parameters

NameTypeDescription
bytesBytebyte array to search
searchBytebyte array to search for

Return

TypeDescription
Intindex of first occurrence, -1 otherwise

Find # native

Searches for the first occurrence of a byte array

function : native : Find(bytes:Byte[], offset:Int, search:Byte[]) ~ Int

Parameters

NameTypeDescription
bytesBytebyte array to search
offsetIntsearch offset
searchBytebyte array to search for

Return

TypeDescription
Intindex of first occurrence, -1 otherwise

FindAll # function

Searches for all occurrences of the byte array

function : FindAll(bytes:Byte[], search:Byte[]) ~ Int[]

Parameters

NameTypeDescription
bytesBytebyte array to search
searchBytebyte array to search for

Return

TypeDescription
Intan array of indexes

IsNeg # function

Checks is a number is negative

function : IsNeg() ~ Bool

Return

TypeDescription
Booltrue if negative, false otherwise

Max # function

Returns the largest byte value

function : Max(l:Byte, r:Byte) ~ Byte

Parameters

NameTypeDescription
lBytevalue to compare
rBytevalue to compare

Return

TypeDescription
Bytelargest byte value

Min # function

Returns the smallest byte value

function : Min(l:Byte, r:Byte) ~ Byte

Parameters

NameTypeDescription
lBytevalue to compare
rBytevalue to compare

Return

TypeDescription
Bytesmallest byte 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:Byte[]) ~ Nil

Parameters

NameTypeDescription
vBytevalues to print

PrintLine # native

Prints values

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

Parameters

NameTypeDescription
vBytevalues to print

ToBinaryString # native

Returns a binary string representation of the value

function : native : ToBinaryString() ~ String

Return

TypeDescription
Stringbinary string representation of the value

ToChar # function

Returns the Character value

function : ToChar() ~ Char

Return

TypeDescription
Charvalue

ToFloat # function

Returns the Float value

function : ToFloat() ~ Float

Return

TypeDescription
Floatvalue

ToFloats # function

Reads floats from raw bytes, 8 per value, little-endian (Float->ToBytes writes them). Raises a RuntimeError, which a try/on or ?-> region can recover from, when the size is not a multiple of 8.

function : ToFloats(bytes:Byte[]) ~ Float[]

Parameters

NameTypeDescription
bytesBytebytes

Return

TypeDescription
Floatbytes->Size() / 8 values

ToFloats # function

Reads floats from raw bytes, 8 per value, little-endian, starting at a byte offset. Raises an IndexError, which a try/on or ?-> region can recover from, when count * 8 bytes from the offset do not fit.

function : ToFloats(bytes:Byte[], offset:Int, count:Int) ~ Float[]

Parameters

NameTypeDescription
bytesBytebytes
offsetIntfirst byte's index
countIntnumber of values

Return

TypeDescription
Floatcount values

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->As(Byte)->ToHexDigits(4)->PrintLine(); # 00ff

ToHexString # native

Returns a positive hexadecimal string representation of the value

function : native : ToHexString() ~ String

Return

TypeDescription
Stringhexadecimal string representation of the value

ToHexString # native

Returns the bytes as a hex digest: two lower-case hex digits per byte, in order, with no prefix or separators. For one byte's value with a 0x prefix, see ToHexString(Byte); for its digits at a given width, ToHexDigits.

function : native : ToHexString() ~ String

Return

TypeDescription
Stringhex digits, two per byte; empty for an empty array

Example

Cipher.Hash->SHA256("Rosetta code"->ToByteArray())->ToHexString()->PrintLine(); # 764faf5c...

ToInt # function

Returns the Int value

function : ToInt() ~ Int

Return

TypeDescription
Intvalue

ToInts # function

Reads integers from raw bytes, 8 per value, little-endian (Int->ToBytes writes them). Raises a RuntimeError, which a try/on or ?-> region can recover from, when the size is not a multiple of 8.

function : ToInts(bytes:Byte[]) ~ Int[]

Parameters

NameTypeDescription
bytesBytebytes

Return

TypeDescription
Intbytes->Size() / 8 values

ToInts # function

Reads integers from raw bytes, 8 per value, little-endian, starting at a byte offset. Raises an IndexError, which a try/on or ?-> region can recover from, when count * 8 bytes from the offset do not fit.

function : ToInts(bytes:Byte[], offset:Int, count:Int) ~ Int[]

Parameters

NameTypeDescription
bytesBytebytes
offsetIntfirst byte's index
countIntnumber of values

Return

TypeDescription
Intcount values

ToString # native

Returns a string representation of the value

function : native : ToString() ~ String

Return

TypeDescription
Stringstring representation of the value

ToString # native

Returns a string representation of the byte array

function : native : ToString(v:Byte[]) ~ String

Parameters

NameTypeDescription
vBytebyte array

Return

TypeDescription
Stringstring representation of the byte array

ToString # function

Returns a string representation of the byte array

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

Parameters

NameTypeDescription
vBytebyte array

Return

TypeDescription
Stringstring representation of the byte array

ToUnicode # function

Converts the byte array to a character array

function : ToUnicode(b:Byte[]) ~ Char[]

Parameters

NameTypeDescription
bBytearray

Return

TypeDescription
Charcharacter array

TryUncompressZlib # function

Uncompresses a zlib byte stream without raising. Use it on data that did not come from the program itself, a file or a download that may be damaged, truncated or not zlib at all: UncompressZlib(input) ends the program for those.

function : TryUncompressZlib(input:Byte[]) ~ Byte[]

Parameters

NameTypeDescription
inputBytezlib bytes, may be Nil

Return

TypeDescription
Byteuncompressed bytes, Nil if the input is Nil or not a whole zlib stream

Example

raw := Byte->TryUncompressZlib(packed);
if(raw = Nil) {
  "not a zlib stream"->ErrorLine();
};

UncompressDeflate # function

Uncompresses a raw deflate (RFC 1951) byte stream, as written by CompressDeflate, a zip member or zlib with windowBits -15. Raises on damaged or truncated input.

function : UncompressDeflate() ~ Byte[]

Return

TypeDescription
Byteuncompressed bytes

UncompressDeflate # function

Uncompresses a raw deflate (RFC 1951) stream to at most 'limit' bytes. A zip member names its uncompressed size, so passing that size as the limit both bounds the memory used and catches a member that expands past what it claims (a zip bomb). Raises on damaged or truncated input, as UncompressDeflate(input) does.

function : UncompressDeflate(input:Byte[], limit:Int) ~ Byte[]

Parameters

NameTypeDescription
inputByteraw deflate bytes
limitIntmost bytes the output may hold

Return

TypeDescription
Byteuncompressed bytes, Nil if the output would be larger than the limit

Example

raw := Byte->UncompressDeflate(member, declared_size);
if(raw = Nil | raw->Size() <> declared_size) {
  "the member does not match its stated size"->ErrorLine();
};

UncompressGzip # function

Uncompresses a byte stream using gzip

function : UncompressGzip() ~ Byte[]

Return

TypeDescription
Byteuncompressed bytes

UncompressGzip # function

Uncompresses a gzip stream to at most 'limit' bytes. Use it on data from outside the program: a few kilobytes of gzip can expand to gigabytes, and this stops at the bound instead of allocating them. Raises on damaged or truncated input, as UncompressGzip(input) does.

function : UncompressGzip(input:Byte[], limit:Int) ~ Byte[]

Parameters

NameTypeDescription
inputBytegzip bytes
limitIntmost bytes the output may hold

Return

TypeDescription
Byteuncompressed bytes, Nil if the output would be larger than the limit

Example

raw := Byte->UncompressGzip(packed, 64 * 1024 * 1024);
if(raw = Nil) {
  "larger than 64 MB uncompressed"->ErrorLine();
};

UncompressZlib # function

Uncompresses a byte stream using zlib

function : UncompressZlib() ~ Byte[]

Return

TypeDescription
Byteuncompressed bytes