本文整理汇总了PHP中Number::of方法的典型用法代码示例。如果您正苦于以下问题:PHP Number::of方法的具体用法?PHP Number::of怎么用?PHP Number::of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Number
的用法示例。
在下文中一共展示了Number::of方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compareTo
/**
* Compares this BigDecimal with the specified BigDecimal.
*
* Two BigDecimal objects that are equal in value but have a different scale (like 2.0 and 2.00)
* are considered equal by this method. This method is provided in preference to individual
* methods for each of the six boolean comparison operators (<, ==, >, >=, !=, <=).
* The suggested idiom for performing these comparisons is: (x.compareTo(y) <op> 0),
* where <op> is one of the six comparison operators.
*
* @param Number|float|int|string $that
*
* @return int - -1, 0, or 1 as this BigDecimal is numerically less than, equal to, or greater than val.
*
* @throws \DivisionByZeroError
*/
public function compareTo($that)
{
$that = Number::of($that);
if ($that instanceof BigInteger) {
$that = $that->toBigDecimal();
}
if ($that instanceof self) {
$this->scaleValues($this, $that, $a, $b);
return Math::cmp($a, $b);
}
return -$that->compareTo($this);
}