Arithmetic#

Bit Shifts#

Arokettu\Unsigned\shift_left(string $value, int $shift) string#

$value << $shift

Arokettu\Unsigned\shift_right(string $value, int $shift) string#

$value >> $shift

Addition and Subtraction#

Arokettu\Unsigned\add(string $a, string $b) string#

$a + $b

Arokettu\Unsigned\add_int(string $a, int $b) string#

$a + $b optimized for small integers

Arokettu\Unsigned\sub(string $a, string $b) string#

$a - $b

Arokettu\Unsigned\sub_int(string $a, int $b) string#

$a - $b optimized for small subtrahends

Arokettu\Unsigned\sub_int_rev(int $a, string $b) string#

$a - $b optimized for small minuends

Multiplication#

Arokettu\Unsigned\mul(string $a, string $b) string#

$a * $b

Arokettu\Unsigned\mul_int(string $a, int $b) string#

$a * $b optimized for small integers

Division#

Arokettu\Unsigned\div_mod(string $a, string $b) [string, string]#

$a /% $b

Returns:

[quotient, remainder]

Arokettu\Unsigned\div_mod_int(string $a, int $b) [string, int]#

$a /% $b optimized for small divisors

Returns:

[quotient, remainder]

Arokettu\Unsigned\div(string $a, string $b) string#

$a / $b

Arokettu\Unsigned\div_int(string $a, int $b) string#

$a / $b optimized for small divisors

Arokettu\Unsigned\mod(string $a, string $b) string#

$a % $b

Arokettu\Unsigned\mod_int(string $a, int $b) int#

$a % $b optimized for small divisors

Returns:

Result is integer because if $b can be represented as native integer, remainder can be too

Comparison#

Arokettu\Unsigned\compare(string $a, string $b) int#

$a <=> $b

Returns:

Same values as the spaceship operator

Bit manipulation#

Arokettu\Unsigned\is_bit_set(string $a, int $bit) bool#
Parameters:
  • $bit (int) – Bit number, 0 is the least significant bit

Returns:

If $bit’th bit is set

Arokettu\Unsigned\set_bit(string $a, int $bit) string#

Set $bit’th bit to 1

Parameters:
  • $bit (int) – Bit number, 0 is the least significant bit

Arokettu\Unsigned\unset_bit(string $a, int $bit) string#

Set $bit’th bit to 0

Parameters:
  • $bit (int) – Bit number, 0 is the least significant bit