Litipk\BigNumbers\Decimal::innerRound PHP Method

innerRound() private static method

"Rounds" the decimal string to have at most $scale digits after the point
private static innerRound ( string $value, integer $scale ) : string
$value string
$scale integer
return string
    private static function innerRound($value, $scale = 0)
    {
        $rounded = bcadd($value, '0', $scale);
        $diffDigit = bcsub($value, $rounded, $scale + 1);
        $diffDigit = (int) $diffDigit[strlen($diffDigit) - 1];
        if ($diffDigit >= 5) {
            if ($diffDigit >= 5 && $value[0] !== '-') {
                $rounded = bcadd($rounded, bcpow('10', -$scale, $scale), $scale);
            } else {
                $rounded = bcsub($rounded, bcpow('10', -$scale, $scale), $scale);
            }
        }
        return $rounded;
    }