File tree Expand file tree Collapse file tree
src/Crisu83/Conversion/Quantity Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ public function add($quantity, $unit = null)
6363 /** @var Quantity $quantity */
6464 $ quantity = new static ($ quantity , $ unit );
6565 $ quantity ->to ($ this ->unit );
66- $ this ->value += $ quantity ->getValue ();
66+ $ this ->value = bcadd ( $ this -> value , $ quantity ->getValue () );
6767 return $ this ;
6868 }
6969
@@ -81,7 +81,7 @@ public function sub($quantity, $unit = null)
8181 /** @var Quantity $quantity */
8282 $ quantity = new static ($ quantity , $ unit );
8383 $ quantity ->to ($ this ->unit );
84- $ this ->value -= $ quantity ->getValue ();
84+ $ this ->value = bcsub ( $ this -> value , $ quantity ->getValue () );
8585 return $ this ;
8686 }
8787
@@ -106,7 +106,7 @@ public function to($unit)
106106 */
107107 protected function convert ($ from , $ to , $ value )
108108 {
109- return ( $ value * $ this ->getConversionRate ($ from )) / $ this ->getConversionRate ($ to );
109+ return bcdiv ( bcmul ( $ value, $ this ->getConversionRate ($ from )), $ this ->getConversionRate ($ to) );
110110 }
111111
112112 /**
You can’t perform that action at this time.
0 commit comments