-
-
Notifications
You must be signed in to change notification settings - Fork 0
Wiki NumInt
final class \FireHub\Core\Support\LowLevel\NumInt()
Important
This class is marked as final.
An int is a number of the set Z = {..., -2, -1, 0, 1, 2, ...}. Int can be specified in decimal (base 10), hexadecimal (base 16), octal (base 8) or binary (base 2) notation. The negation operator can be used to denote a negative int.
This class was created by Danijel Galić <danijel.galic@outlook.com>
Copyright: 2024 FireHub Web Application Framework
License: <https://opensource.org/licenses/OSL-3.0> OSL Open Source License version 3
Version: GIT: $Id$ Blob checksum.
Fully Qualified Class Name: \FireHub\Core\Support\LowLevel\NumInt
Source code: view source code
Blame: view blame
History: view history
Type | Name | Title |
---|---|---|
public static | divide | ### Integer division |
inherited public static | absolute | ### Absolute value |
inherited public static | ceil | ### Round fractions up |
inherited public static | floor | ### Round fractions down |
inherited public static | round | ### Rounds a float |
inherited public static | log | ### Natural logarithm |
inherited public static | log1p | ### Returns log(1 + number), computed in a way that is accurate even when the value of number is close to zero |
inherited public static | log10 | ### Base-10 logarithm |
inherited public static | max | ### Find highest value |
inherited public static | min | ### Find lowest value |
inherited public static | power | ### Exponential expression |
inherited public static | format | ### Format a number with grouped thousands |
public static NumInt::divide(int $dividend, int $divisor):int
Source code: view source code
Blame: view blame
- int $dividend - Number to be divided.
- int $divisor -
non-zero-int
Number which divides the $dividend.
- \ArithmeticError - If the $dividend is PHP_INT_MIN and the $divisor is -1.
- \DivisionByZeroError - If $divisor is 0.
- int - The integer quotient of the division of $dividend by $divisor.
final public static Num::absolute(float|int $number):int|float
Important
This method is marked as final.
Returns the absolute value of $number.
Source code: view source code
Blame: view blame
- float or int $number - The numeric value to process.
- int or float -
($number is int ? int : float)
The absolute value of number.
final public static Num::ceil(float|int $number):int
Important
This method is marked as final.
Returns the next highest integer value by rounding up $number if necessary.
Source code: view source code
Blame: view blame
- float or int $number - The value to round up.
- int - Rounded number up to the next highest integer.
final public static Num::floor(float|int $number):int
Important
This method is marked as final.
Returns the next lowest integer value (as float) by rounding down $number if necessary.
Source code: view source code
Blame: view blame
- float or int $number - The value to round down.
- int - Rounded number up to the next lowest integer.
final public static Num::round(float|int $number, int $precision, \FireHub\Core\Support\Enums\Number\Round $round = Round::HALF_UP):float|int
Important
This method is marked as final.
Returns the rounded value of $number to specified $precision (number of digits after the decimal point). $precision can also be negative or zero (default).
Source code: view source code
Blame: view blame
- float or int $number - The value to round.
- int $precision - [optional] Number of decimal digits to round to. If the precision is positive, num is rounded to precision significant digits after the decimal point. If the precision is negative, num is rounded to precision significant digits before the decimal point, i.e., to the nearest multiple of pow(10, -$precision), e.g. for a precision of -1 num is rounded to tens, for a precision of -2 to hundreds, etc.
- \FireHub\Core\Support\Enums\Number\Round $round = Round::HALF_UP - [optional] Specify the mode in which rounding occurs.
- float or int -
($precision is positive-int ? float : int)
Rounded number float.
final public static Num::log(float|int $number, \FireHub\Core\Support\Enums\Number\LogBase|float $base = LogBase::E):float
Important
This method is marked as final.
Source code: view source code
Blame: view blame
- float or int $number - The value to calculate the logarithm for.
- \FireHub\Core\Support\Enums\Number\LogBase or float $base = LogBase::E - [optional] The optional logarithmic base to use (defaults to 'e' and so to the natural logarithm).
- float - The logarithm of $number to $base, if given, or the natural logarithm.
final public static Num::log1p(float|int $number):float
Important
This method is marked as final.
### Returns log(1 + number), computed in a way that is accurate even when the value of number is close to zero
Source code: view source code
Blame: view blame
- float or int $number - The argument to process.
- float - log(1 + num).
final public static Num::log10(float|int $number):float
Important
This method is marked as final.
Source code: view source code
Blame: view blame
- float or int $number - The argument to process.
- float - The base-10 logarithm of num.
final public static Num::max(\FireHub\Core\Support\LowLevel\TInt $value, \FireHub\Core\Support\LowLevel\TInt ...$values):int|float
Important
This method is marked as final.
Source code: view source code
Blame: view blame
- TInt of int|float
-
\FireHub\Core\Support\LowLevel\TInt $value -
TInt
Any comparable value. - variadic \FireHub\Core\Support\LowLevel\TInt $values -
TInt
Any comparable values.
- int or float -
TInt
Value considered "highest" according to standard comparisons.
final public static Num::min(\FireHub\Core\Support\LowLevel\TInt $value, \FireHub\Core\Support\LowLevel\TInt ...$values):int|float
Important
This method is marked as final.
Source code: view source code
Blame: view blame
- TInt of int|float
-
\FireHub\Core\Support\LowLevel\TInt $value -
TInt
Any comparable value. - variadic \FireHub\Core\Support\LowLevel\TInt $values -
TInt
Any comparable values.
- int or float -
TInt
Value considered "lowest" according to standard comparisons.
final public static Num::power(float|int $base, float|int $exponent):float|int
Important
This method is marked as final.
Note
It is possible to use the ** operator instead.
Source code: view source code
Blame: view blame
- float or int $base - The base to use.
- float or int $exponent - The exponent.
- float or int - Base raised to the power of exponent. If both arguments are non-negative integers and the result can be represented as an integer, the result will be returned with an int type, otherwise it will be returned as a float.
final public static Num::format(int|float $number, int $decimals, string $decimal_separator = '.', string $thousands_separator = ','):string
Important
This method is marked as final.
Formats a number with grouped thousands and optionally decimal digits using the rounding half up rule.
Source code: view source code
Blame: view blame
- int or float $number - The number being formatted.
- int $decimals -
non-negative-int
Sets the number of decimal digits. If 0, the decimal_separator is omitted from the return value. - string $decimal_separator = '.' - Sets the separator for the decimal point.
- string $thousands_separator = ',' - Sets the separator for thousands.
- string - A formatted version of number.
Build with phpDocumentor using template FireHub phpDocumentor Wiki Template.