If the fraction of the amount is exactly 0.5, then return the amount - 0.5.

@param string $amount the amount to round

@return string
547263
private static function roundHalfDown($amount)
    {
        $result = self::roundToNearestIntegerIgnoringTies($amount);

        if (null == $result) {
            $result = self::roundToNearestIntegerIgnoringTies(bcsub($amount, '0.1', self::BCSCALE));
        }

        return $result;
    }
295172
public function lighten($amount)
    {
        if ($amount < 0 || $amount > 100) {
            throw new InvalidArgumentException('The given amount must be between 0 and 100');
        }
        $amount /= 100;
        $this->lightness += (100 - $this->lightness) * $amount;

        return $this;
    }
1302507
public function refund($amount = null)
    {
        $builder = new HpsCreditServiceRefundBuilder($this);
        return $builder
            ->withAmount($amount)
            ->withCurrency('usd');
    }
722841
private function LightenColor($color, $amount)
    {
        $newColor = $color + (0xff - $color) * $amount;
        return min(max(round($newColor), 0x00), 0xff);
    }
109048
protected function getClosestAcceptedCashAmount($amount): int
    {
        $value = Number::fromString($amount)->getIntegerPart();
        $cent = $amount % 5;

        if ($cent <= 2) {
            $value = $value - $cent;
        } else {
            $value = $value + (5 - $cent);
        }

        return $value;
    }
1151945
public function setAmount($amount)
    {
        if ($amount === null) {
            $this->amount = 0;
            return $this;
        }
        
        if (!is_int($amount)) {
            throw new InvalidArgumentException(sprintf(
                'Amount must be an integer, "%s" given',
                is_object($amount) ? get_class($amount) : gettype($amount)
            ));
        }
        
        // Overflow check is not necessary because we have an integer
        $this->amount = $amount;
        return $this;
    }
1267505
public static function parse(string $amount)
    {
        $parser = new DecimalMoneyParser(new ISOCurrencies());

        return static::given(
            $parser->parse($amount, new Currency('MYR'))->getAmount()
        );
    }
367397
public function creditCardPartial($amount)
    {
        $data = new stdClass();
        $data->amount = $amount;

        return $this->execute($data);
    }
338386
public function subtract($amount)
    {
        if ($amount instanceof FeeContract) {
            return $amount->subtract($this)->convertTo($this->currency());
        }

        throw_unless($amount instanceof Amount, BadMethodCallException::class);

        return new static(
            $this->amount - $amount->convertTo($this->currency())->amount,
            $this->currency()
        );
    }
324850
private static function roundHalfToEven($amount)
    {
        $result = self::roundToNearestIntegerIgnoringTies($amount);

        if (null == $result) {
            $truncated = self::roundHalfTowardsZero($amount);

            if (0 == bcmod($truncated, '2')) { // Even
                $result = $truncated;
            } else {
                $result = self::roundHalfAwayFromZero($amount);
            }
        }

        return $result;
    }
1267934
private function getAmount($amount, $currency)
    {
        $list = self::getCurrencyList();

        if (!isset($list[$currency])) {
            throw new \RuntimeException('Invalid currency provided');
        }

        return (int) (100 * bcmul('1', (string) $amount, $list[$currency]['fraction']));
    }
38972
public function formatAmount($amount, $currency = null)
    {
        return str_replace('.00', '', $this->moneyHelper->formatAmount($amount, $currency));
    }
1231308
private function roundDigit(Number $number)
    {
        if ($number->isCloserToNext()) {
            return $this->add(
                $number->getIntegerPart(),
                $number->getIntegerRoundingMultiplier()
            );
        }

        return $this->add($number->getIntegerPart(), '0');
    }
839447
public function getPrice($format = self::EURO)
    {
        $this->validatePriceFormat($format);

        if ($this->price !== null && $format == self::EURO) {
            return round($this->price / 100, 2);
        }

        return $this->price;
    }
368360
public static function formatAmount(int $amount): string
    {
        if (static::$formatCurrencyUsing) {
            return call_user_func(static::$formatCurrencyUsing, $amount);
        }
        $amount = number_format($amount / 100, 2);
        if (StringHelper::startsWith($amount, '-')) {
            return '-' . static::usesCurrencySymbol() . ltrim($amount, '-');
        }

        return static::usesCurrencySymbol() . $amount;
    }
1228642
public function transformToCurrency($amount, $locale, $currency)
    {
        $localeClassName = $this->resolveLocaleClassName($locale);
        $transformer = new $localeClassName($this->options);

        $decimalPart = (int) ($amount / 100);
        $fractionalPart = $amount % 100;

        if (0 === $fractionalPart) {
            return trim($transformer->toCurrencyWords($currency, $decimalPart));
        }

        return trim($transformer->toCurrencyWords($currency, $decimalPart, $fractionalPart));
    }
940492
protected function parseAmountDecimalSeparator($amount) {
    $decimal_separator_counts = [];
    foreach ($this->decimalSeparators as $decimal_separator) {
      $decimal_separator_counts[$decimal_separator] = \mb_substr_count($amount, $decimal_separator);
    }
    $decimal_separator_counts_filtered = array_filter($decimal_separator_counts);
    if (count($decimal_separator_counts_filtered) > 1 || reset($decimal_separator_counts_filtered) !== FALSE && reset($decimal_separator_counts_filtered) != 1) {
      return FALSE;
    }
    return str_replace($this->decimalSeparators, '.', $amount);
  }