Litipk\BigNumbers\Decimal::round PHP Method

round() public method

"Rounds" the Decimal to have at most $scale digits after the point
public round ( integer $scale ) : Decimal
$scale integer
return Decimal
    public function round($scale = 0)
    {
        if ($scale >= $this->scale) {
            return $this;
        }
        return self::fromString(self::innerRound($this->value, $scale));
    }

Usage Example

コード例 #1
0
ファイル: Money.php プロジェクト: coolms/money
 /**
  * Useful for payment systems that don't use high precision
  *
  * @param int $roundingMode
  * @return Decimal
  */
 public function toUnits($roundingMode = self::ROUND_HALF_UP)
 {
     $this->assertRoundingMode($roundingMode);
     $precision = $this->getPrecision();
     if (null === $roundingMode) {
         return $this->amount->round($precision);
     }
     return Math::bcround($this->amount, $precision, $roundingMode);
 }