public function round($value) { foreach ($this->ranges as $to => $rounder) { if ($value <= (int) $to || $to === "*") { if ($rounder instanceof \Closure) { $value = $rounder($value); } else { if ($rounder instanceof Rounder) { $value = $rounder->round($value); } } return parent::round($value); } } throw new \Exception("Unable to round value: {$value}"); }
public function round($value) { $multiplier = pow(10, $this->factor); if (Rounder::ROUND_HALF_UP == $this->mode || Rounder::ROUND_HALF_DOWN == $this->mode) { $value = (round($value / $multiplier, $this->precision, $this->mode) - $this->cents) * $multiplier; } else { if (Rounder::ROUND_CEIL == $this->mode) { // echo '$multiplier => ' . $multiplier . PHP_EOL; // echo '$value / $multiplier => ' . ($value / $multiplier) . PHP_EOL; // echo 'ceil($value / $multiplier) => ' . (ceil($value / $multiplier)) . PHP_EOL; // echo '(ceil($value / $multiplier) - $this->cents) => ' . ((ceil($value / $multiplier) - $this->cents)) . PHP_EOL; // $value = (ceil($value / $multiplier) - $this->cents) * $multiplier; $value = round((ceil($value / $multiplier) - $this->cents) * $multiplier, $this->precision, $this->mode); } } return parent::round($value); }
public function round($value) { $candidates = $this->findCandidates($value); $analysis = $this->analyze($candidates, $value); return parent::round($analysis["best"]); }
public function round($value) { return parent::round(round($values * 2, $this->precision, $this->mode) / 2); }