num

php\lib\num

Utils for numbers

Class num

Methods


__construct()

private

static compare($num1, $num2)

Compare two numbers

Note

it can be used as comparator for number sorting

Parameters:
  • $num1int, double
  • $num2int, double
Returns:

int 0 if are equal, 1 if $num1 > $num2, -1 if $num1 < $num2

static toBin($number)

Returns a string representation of the $number argument as an unsigned integer in base 2.

Parameters:
  • $numberint
Returns:

string

static toOctal($number)

Returns a string representation of the $number argument as an unsigned integer in base 8.

Parameters:
  • $numberint
Returns:

string

static toHex($number)

Returns a string representation of the $number argument as an unsigned integer in base 16.

Parameters:
  • $numberint
Returns:

string

static toString($number, $radix)

Returns a string representation of the first argument in the radix specified by the second argument.

Parameters:
  • $numberint
  • $radixint
Returns:

string

static reverse($number)

Returns the value obtained by reversing the order of the bits in the two’s complement binary representation of the specified {@code long} value.

Parameters:
  • $numberint
Returns:

int

static decode($string)

Decodes a string into a integer. Accepts decimal, hexadecimal, and octal numbers

Parameters:
  • $stringstring
Returns:

string or false if invalid number format

static format($number, $pattern, $decSep = '.', $groupSep = ', ')
Parameters:
  • $numberint, double
  • $pattern
  • $decSepstring
  • $groupSepstring
Returns:

string