Menu
UInt64Array
final class UInt64Array<T> extends IntTypedArray
64-bit unsigned elements. PHP has no unsigned int, so an element READS as the int with the same 64 bits — a value of 2^63 or more reads negative — and an int WRITES its bits, so $a[$i] = $a[$j] copies any value. A numeric string or a float is a VALUE: 0..18446744073709551615, anything else is a ValueError. Ordering (min, max, compare) is unsigned; getString() gives the decimal value.
Type parameters
T- = int
Methods
getString() | Element $index as its unsigned decimal value. |
compare() | -1, 0 or 1 as $a is below, equal to or above $b, both read as unsigned. |
jsonSerialize() | Every element as its unsigned decimal value: JSON numbers have no width, so one past 2^63 is written exactly — a Go / Rust / BigInt consumer reads 18446744073709551615, not -1. |
toDecimal() | The unsigned decimal value of 64 bits. |
getString()#source
function getString(int $index): string
Element $index as its unsigned decimal value.
Parameters
$indexint- the position
Returns
string — the decimal digits, e.g. '18446744073709551615'
Throws
- \OutOfBoundsException
- when the position is outside
0..count-1
compare()#source
static function compare(int $a, int $b): int
-1, 0 or 1 as $a is below, equal to or above $b, both read as unsigned.
Parameters
$aint- the first 64-bit pattern
$bint- the second 64-bit pattern
Returns
int — -1, 0 or 1
jsonSerialize()#source
function jsonSerialize(): array
Every element as its unsigned decimal value: JSON numbers have no width, so one past 2^63 is written exactly — a Go / Rust / BigInt consumer reads 18446744073709551615, not -1. toArray() stays on bits. Decode it back losslessly with JSON_BIGINT_AS_STRING and fromArray().
Returns
array<int, mixed> — the elements as a list; values of 2^63 or more as exact decimal numbers
toDecimal()#source
static function toDecimal(int $bits): string
The unsigned decimal value of 64 bits.
Parameters
$bitsint- an
intread as an unsigned 64-bit pattern
Returns
string — the decimal digits