DiscordPHP Documentation

BigInt
in package

Polyfill to handle big integer operation in 32 bit PHP using ext-gmp.

Tags
since
10.0.0

Renamed from Bitwise to BigInt

since
7.0.0

Table of Contents

$is_32_gmp  : bool
add()  : GMP|int
and()  : GMP|int
floatCast()  : string|mixed
Safely converts float to string, avoiding locale-dependent issues.
is32BitWithGMP()  : bool
not()  : GMP|int
or()  : GMP|int
set()  : GMP|int
shiftLeft()  : GMP|int
shiftRight()  : GMP|int
sub()  : GMP|int
test()  : bool
xor()  : GMP|int

Properties

$is_32_gmp

private static bool $is_32_gmp = false

Methods

add()

public static add(GMP|int|string $num1, GMP|int|string $num2) : GMP|int
Parameters
$num1 : GMP|int|string
$num2 : GMP|int|string
Return values
GMP|int

$num1 + $num2

and()

public static and(GMP|int|string $num1, GMP|int|string $num2) : GMP|int
Parameters
$num1 : GMP|int|string
$num2 : GMP|int|string
Return values
GMP|int

$num1 & $num2

floatCast()

Safely converts float to string, avoiding locale-dependent issues.

public static floatCast(mixed $value) : string|mixed
Parameters
$value : mixed

if not a float, it is discarded

Tags
link
https://github.com/brick/math/pull/20
Return values
string|mixed

string if value is a float, otherwise discarded

is32BitWithGMP()

public static is32BitWithGMP() : bool
Return values
bool

Whether the GMP extension is loaded

not()

public static not(GMP|int|string $value) : GMP|int
Parameters
$value : GMP|int|string
Return values
GMP|int

~ $value

or()

public static or(GMP|int|string $num1, GMP|int|string $num2) : GMP|int
Parameters
$num1 : GMP|int|string
$num2 : GMP|int|string
Return values
GMP|int

$num1 | $num2

set()

public static set(GMP|int|string $num1, int $num2) : GMP|int
Parameters
$num1 : GMP|int|string
$num2 : int
Return values
GMP|int

$num1 |= (1 << $num2)

shiftLeft()

public static shiftLeft(GMP|int|string $num1, int $num2) : GMP|int
Parameters
$num1 : GMP|int|string
$num2 : int
Return values
GMP|int

$num1 << $num2

shiftRight()

public static shiftRight(GMP|int|string $num1, int $num2) : GMP|int
Parameters
$num1 : GMP|int|string
$num2 : int
Return values
GMP|int

$num1 >> $num2

sub()

public static sub(GMP|int|string $num1, GMP|int|string $num2) : GMP|int
Parameters
$num1 : GMP|int|string
$num2 : GMP|int|string
Return values
GMP|int

$num1 - $num2

test()

public static test(GMP|int|string $num1, int $num2) : bool
Parameters
$num1 : GMP|int|string
$num2 : int
Return values
bool

$num1 & (1 << $num2)

xor()

public static xor(GMP|int|string $num1, GMP|int|string $num2) : GMP|int
Parameters
$num1 : GMP|int|string
$num2 : GMP|int|string
Return values
GMP|int

$num1 ^ $num2

Search results