You are here

protected function Fraction::bcRound in Fraction 7

BCMath decimal rounding function.

Parameters

$value: The value to round.

$precision: The desired decimal precision.

Return value

string Returns a rounded decimal value, as a PHP string.

1 call to Fraction::bcRound()
Fraction::toDecimal in ./fraction.class.inc
Calculate the decimal equivalent of the fraction.

File

./fraction.class.inc, line 458
Fraction class

Class

Fraction
@file Fraction class

Code

protected function bcRound($value, $precision) {
  if ($value[0] != '-') {
    return bcadd($value, '0.' . str_repeat('0', $precision) . '5', $precision);
  }
  return bcsub($value, '0.' . str_repeat('0', $precision) . '5', $precision);
}