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:
- $num1 – int, double
- $num2 – int, 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:
- $number – int
Returns: string
- static
toOctal
($number)¶Returns a string representation of the $number argument as an unsigned integer in base 8.
Parameters:
- $number – int
Returns: string
- static
toHex
($number)¶Returns a string representation of the $number argument as an unsigned integer in base 16.
Parameters:
- $number – int
Returns: string
- static
toString
($number, $radix)¶Returns a string representation of the first argument in the radix specified by the second argument.
Parameters:
- $number – int
- $radix – int
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:
- $number – int
Returns: int
- static
decode
($string)¶Decodes a string into a integer. Accepts decimal, hexadecimal, and octal numbers
Parameters:
- $string – string
Returns: string or false if invalid number format
- static
format
($number, $pattern, $decSep = '.', $groupSep = ', ')¶
Parameters:
- $number – int, double
- $pattern –
- $decSep – string
- $groupSep – string
Returns: string