bcmath - Decimal multiplication in php -
i having problem multiplication of 2 decimals 30.63
, 0.15
. calculator says should result in 4.60
.
$commission = bcmul(30.63, 0.15,2);
result 4.59
.
from had read bcmul meant work decimal numbers?
many thanks,
from the documentation $scale
parameter bcmul
:
this optional parameter used set number of digits after decimal place in result.
this means number rounded down (or negative number) when it's used, e.g.
> echo bcmul(0.99, 1, 1); 0.9
for values, 30.63 * 0.15 equal 4.5945. supplying $scale
value of 2 means 4.59, you've reported.
i'm not sure why you're expecting 4.60, unless you're expecting result rounded up.
Comments
Post a Comment