2 declare(strict_types=1);
13 private $bytes = [0, 0, 0, 0, 0, 0, 0, 0];
22 $this->fillBytes($value, 0, 8);
35 for (
$i = 0;
$i < $count;
$i++) {
36 $this->bytes[$start +
$i] =
$i >= PHP_INT_SIZE ? 0 : $value & 0xFF;
47 public static function init(
int $value = 0): self
49 return new self($value);
62 $bigint->fillBytes($low, 0, 4);
63 $bigint->fillBytes($high, 4, 4);
74 return $this->getValue(4, 4);
100 public function getLowFF(
bool $force =
false): float
102 if ($force || $this->isOver32()) {
103 return (
float)0xFFFFFFFF;
105 return (
float)$this->getLow32();
114 public function isOver32(
bool $force =
false): bool
118 max(array_slice($this->bytes, 4, 4)) > 0 ||
119 min(array_slice($this->bytes, 0, 4)) === 0xFF;
129 return $this->getValue(0, 4);
140 for (
$i = 7;
$i >= 0;
$i--) {
141 $result .= sprintf(
'%02X', $this->bytes[
$i]);
156 for (
$i = 0;
$i < 8;
$i++) {
getValue(int $end=0, int $length=8)
Get value from bytes array.
static init(int $value=0)
Get an instance.
isOver32(bool $force=false)
Check if is over 32.
static fromLowHigh(int $low, int $high)
Fill bytes from low to high.
fillBytes(int $value, int $start, int $count)
Fill the bytes field with int.
getLowFF(bool $force=false)
Get low FF.
__construct(int $value=0)
Initialize the bytes array.
getHex64()
Get hexadecimal.