protected function Fraction::bcRound in Fraction 8
Same name and namespace in other branches
- 2.x src/Fraction.php \Drupal\fraction\Fraction::bcRound()
BCMath decimal rounding function.
Parameters
$value: The value to round.
int $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 src/Fraction.php 
- Calculates the decimal equivalent of the fraction.
File
- src/Fraction.php, line 396 
Class
- Fraction
- A simple class for representing and acting upon a fraction.
Namespace
Drupal\fractionCode
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);
}