trait NumberTrait

Numbers Helpers

Methods

string
numberAdd(mixed $a, mixed $b, int $scale = 2)

数值相加

string
numberSubtract(mixed $a, mixed $b, int $scale = 2)

减法

string
numberMultiply(mixed $a, mixed $b, int $scale = 2)

乘法计算

string
numberDivide(mixed $a, mixed $b, int $scale = 2)

除法

string
numberFee(mixed $amount, mixed $fee_rate = 0.0, int $scale = 2)

计算费率

int
numberCompare(mixed $a, mixed $b, int $scale = 2)

数值比较

string
numberRound(mixed $a, int $precision = 0, int $scale = 2)

获取字四舍五入串值 Returns the current raw value of this BigNumber

Details

at line 23
string numberAdd(mixed $a, mixed $b, int $scale = 2)

数值相加

Parameters

mixed $a 需要叠加的数据
mixed $b 需要叠加的数据
int $scale

Return Value

string

at line 35
string numberSubtract(mixed $a, mixed $b, int $scale = 2)

减法

Parameters

mixed $a 需要叠加的数据
mixed $b 需要叠加的数据
int $scale

Return Value

string

at line 47
string numberMultiply(mixed $a, mixed $b, int $scale = 2)

乘法计算

Parameters

mixed $a 需要叠加的数据
mixed $b 需要叠加的数据
int $scale

Return Value

string

at line 59
string numberDivide(mixed $a, mixed $b, int $scale = 2)

除法

Parameters

mixed $a 除数
mixed $b 被除数
int $scale 精度

Return Value

string

at line 75
string numberFee(mixed $amount, mixed $fee_rate = 0.0, int $scale = 2)

计算费率

Parameters

mixed $amount 金额
mixed $fee_rate 费率
int $scale

Return Value

string

at line 94
int numberCompare(mixed $a, mixed $b, int $scale = 2)

数值比较

返回值 0: 相等 , 1: a大于b; -1: a小于b

Parameters

mixed $a 数值a
mixed $b 数值b
int $scale

Return Value

int

at line 108
string numberRound(mixed $a, int $precision = 0, int $scale = 2)

获取字四舍五入串值 Returns the current raw value of this BigNumber

Parameters

mixed $a 数值a
int $precision
int $scale

Return Value

string

String representation of the number in base 10