Number
class Number
Represents a number for use with Binary Calculator computations
Properties
protected string | $numberValue | Number value, as a string |
|
protected int | $numberScale | The scale for the current number |
Methods
Constructs a BigNumber object from a string, integer, float, or any object that may be cast to a string, resulting in a numeric string value
Returns the string value of this BigNumber
将当前数字设置为自身的绝对值 Sets the current number to the absolute value of itself
加法运算 Adds the given number to the current number
通过重新排列当前数字来查找下一个最高整型值 Finds the next highest integer value by rounding up the current number if necessary
比较数据 Compares the current number with the given number
进制转换, 转换成任意进制 Returns the current value converted to an arbitrary base
将当前数字的值减一 Decreases the value of the current number by one
除法运算 Divides the current number by the given number
通过舍入当前数字找到下一个最低整数值 Finds the next lowest integer value by rounding down the current number if necessary
返回小数位数 Returns the scale used for this BigNumber
获取字串值 Returns the current raw value of this BigNumber
增加 Increases the value of the current number by one
检测是否相等 Returns true if the current number equals the given number
检测是否大于 Returns true if the current number is greater than the given number
检测大于等于 Returns true if the current number is greater than or equal to the given number
检测小与 Returns true if the current number is less than the given number
检测小与等于 Returns true if the current number is less than or equal to the given number
是否是负数 Returns true if the current number is a negative number
是否是正数 Returns true if the current number is a positive number
取余数 Finds the modulus of the current number divided by the given number
乘法 Multiplies the current number by the given number
返回负数 Sets the current number to the negative value of itself
幂运算 Raises current number to the given number
指定次数的幂运算 Raises the current number to the $pow, then divides by the $mod to find the modulus
设置小数位数 Sets the scale of this BigNumber
设置为一个新值 Sets the value of this BigNumber to a new value
位向左移动 Shifts the current number $bits to the left
位向右移动 Shifts the current number $bits to the right
前数字的符号 Returns the sign (signum) of the current number
求平方根 Finds the square root of the current number
减法 Subtracts the given number from the current number
进制转换 Converts a number between arbitrary bases (from 2 to 36)
转换 10 进制到其他进制 Converts a base-10 number to an arbitrary base (from 2 to 36)
转换成 10 进制 Converts a number from an arbitrary base (from 2 to 36) to base 10
设置默认小数位数 Changes the default scale used by all Binary Calculator functions
转换成 String 类型 Filters a number, converting it to a string value
Details
at line 62
__construct(mixed $number, int $scale = 2)
Constructs a BigNumber object from a string, integer, float, or any object that may be cast to a string, resulting in a numeric string value
at line 76
string
__toString()
Returns the string value of this BigNumber
at line 85
abs()
将当前数字设置为自身的绝对值 Sets the current number to the absolute value of itself
at line 105
$this
add(mixed $number)
加法运算 Adds the given number to the current number
at line 123
ceil()
通过重新排列当前数字来查找下一个最高整型值 Finds the next highest integer value by rounding up the current number if necessary
at line 152
int
compareTo(mixed $number)
比较数据 Compares the current number with the given number
Returns 0 if the two operands are equal, 1 if the current number is larger than the given number, -1 otherwise.
at line 168
string
convertToBase(int $base)
进制转换, 转换成任意进制 Returns the current value converted to an arbitrary base
at line 177
decrement()
将当前数字的值减一 Decreases the value of the current number by one
at line 192
$this
divide(mixed $number)
除法运算 Divides the current number by the given number
at line 216
floor()
通过舍入当前数字找到下一个最低整数值 Finds the next lowest integer value by rounding down the current number if necessary
at line 242
int
getScale()
返回小数位数 Returns the scale used for this BigNumber
If no scale was set, this will default to the value of bcmath.scale in php.ini.
at line 257
string
getValue()
获取字串值 Returns the current raw value of this BigNumber
at line 267
increment()
增加 Increases the value of the current number by one
at line 280
bool
isEqualTo(mixed $number)
检测是否相等 Returns true if the current number equals the given number
at line 293
bool
isGreaterThan(mixed $number)
检测是否大于 Returns true if the current number is greater than the given number
at line 306
bool
isGreaterThanOrEqualTo(mixed $number)
检测大于等于 Returns true if the current number is greater than or equal to the given number
at line 319
bool
isLessThan(mixed $number)
检测小与 Returns true if the current number is less than the given number
at line 332
bool
isLessThanOrEqualTo(mixed $number)
检测小与等于 Returns true if the current number is less than or equal to the given number
at line 343
bool
isNegative()
是否是负数 Returns true if the current number is a negative number
at line 354
bool
isPositive()
是否是正数 Returns true if the current number is a positive number
at line 369
$this
mod(mixed $number)
取余数 Finds the modulus of the current number divided by the given number
at line 394
$this
multiply(mixed $number)
乘法 Multiplies the current number by the given number
at line 409
negate()
返回负数 Sets the current number to the negative value of itself
at line 423
$this
pow(mixed $number)
幂运算 Raises current number to the given number
at line 457
$this
powMod(mixed $pow, mixed $mod)
指定次数的幂运算 Raises the current number to the $pow, then divides by the $mod to find the modulus
This is functionally equivalent to the following code:
$n = new BigNumber(1234);
$n->mod($n->pow(32), 2);
However, it uses bcpowmod(), so it is faster and can accept larger parameters.
at line 487
Number
round(int $precision = 0)
四舍五入 Rounds the current number to the nearest integer
at line 516
$this
setScale(int $scale)
设置小数位数 Sets the scale of this BigNumber
at line 531
$this
setValue(mixed $number)
设置为一个新值 Sets the value of this BigNumber to a new value
at line 552
$this
shiftLeft(int $bits)
位向左移动 Shifts the current number $bits to the left
at line 569
$this
shiftRight(int $bits)
位向右移动 Shifts the current number $bits to the right
at line 585
int
signum()
前数字的符号 Returns the sign (signum) of the current number
at line 603
sqrt()
求平方根 Finds the square root of the current number
at line 622
$this
subtract(mixed $number)
减法 Subtracts the given number from the current number
at line 642
static string
baseConvert(string|int $number, int $fromBase = 10, int $toBase = 16)
进制转换 Converts a number between arbitrary bases (from 2 to 36)
at line 658
static string
convertFromBase10(string|int $number, int $toBase)
转换 10 进制到其他进制 Converts a base-10 number to an arbitrary base (from 2 to 36)
at line 693
static string
convertToBase10(string|int $number, int $fromBase)
转换成 10 进制 Converts a number from an arbitrary base (from 2 to 36) to base 10
at line 736
static void
setDefaultScale(int $scale)
设置默认小数位数 Changes the default scale used by all Binary Calculator functions
at line 748
protected string
filterNumber(mixed $number)
转换成 String 类型 Filters a number, converting it to a string value