num

php\lib\num

Utils for numbers

Class num

Methods


__construct()

private

static compare($num1, $num2)

Compare two numbers

Примечание

it can be used as comparator for number sorting

Параметры:
  • $num1int, double
  • $num2int, double
Результат:

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.

Параметры:
  • $numberint
Результат:

string

static toOctal($number)

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

Параметры:
  • $numberint
Результат:

string

static toHex($number)

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

Параметры:
  • $numberint
Результат:

string

static toString($number, $radix)

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

Параметры:
  • $numberint
  • $radixint
Результат:

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.

Параметры:
  • $numberint
Результат:

int

static decode($string)

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

Параметры:
  • $stringstring
Результат:

string or false if invalid number format

static format($number, $pattern, $decSep = '.', $groupSep = ', ')
Параметры:
  • $numberint, double
  • $pattern
  • $decSepstring
  • $groupSepstring
Результат:

string