Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Crisu83/Conversion/Quantity/Quantity.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function add($quantity, $unit = null)
$quantity = new static($quantity, $unit);
/** @var Quantity $quantity */
$quantity->to($this->unit);
$this->value += $quantity->getValue();
$this->value = bcadd($this->value, $quantity->getValue());
return $this;
}

Expand All @@ -83,7 +83,7 @@ public function sub($quantity, $unit = null)
$quantity = new static($quantity, $unit);
/** @var Quantity $quantity */
$quantity->to($this->unit);
$this->value -= $quantity->getValue();
$this->value = bcsub($this->value, $quantity->getValue());
return $this;
}

Expand All @@ -108,7 +108,7 @@ public function to($unit)
*/
protected function convert($from, $to, $value)
{
return ($value * $this->getConversionRate($from)) / $this->getConversionRate($to);
return bcdiv(bcmul($value, $this->getConversionRate($from)), $this->getConversionRate($to));
}

/**
Expand Down