public function round($decimalDigits = null, $mode = self::ROUND_HALF_AWAY_FROM_ZERO)
    {
        if (null === $decimalDigits) {
            $decimalDigits = $this->currency->getDecimalDigits();
        }

        $factor = bcpow('10', $decimalDigits, self::BCSCALE);
        $amount = bcmul($this->amount, $factor, self::BCSCALE);

        switch ($mode) {
            case self::ROUND_UP:
                $result = self::roundUp($amount);
                break;
            case self::ROUND_DOWN:
                $result = self::roundDown($amount);
                break;
            case self::ROUND_TOWARDS_ZERO:
                $result = self::roundTowardsZero($amount);
                break;
            case self::ROUND_AWAY_FROM_ZERO:
                $result = self::roundAwayFromZero($amount);
                break;
            case self::ROUND_HALF_UP:
                $result = self::roundHalfUp($amount);
                break;
            case self::ROUND_HALF_DOWN:
                $result = self::roundHalfDown($amount);
                break;
            case self::ROUND_HALF_TOWARDS_ZERO:
                $result = self::roundHalfTowardsZero($amount);
                break;
            case self::ROUND_HALF_AWAY_FROM_ZERO:
                $result = self::roundHalfAwayFromZero($amount);
                break;
            case self::ROUND_HALF_TO_EVEN:
                $result = self::roundHalfToEven($amount);
                break;
            case self::ROUND_HALF_TO_ODD:
                $result = self::roundHalfToOdd($amount);
                break;
            default:
                throw new \InvalidArgumentException('Unknown rounding mode \''.$mode.'\'');
        }

        $result = bcdiv($result, $factor, self::BCSCALE);

        return self::valueOf($result, $this->currency);
    }