Reputation: 139
How do i *(Times) Percentage ?
$variable = 2 ;
and i wanted it to times 5.3% , how should i do it ?
$variable * 1.5%; < caused error
============================
Think a new ways thanks to @Barmar
By Adding new variable s
$percentage = 0.53; $finalprice = $variable + ($variable * $percentage)
Upvotes: 0
Views: 324
Reputation: 780714
Convert a percentage to a number by dividing by 100, e.g. 5.3% = 0.053
.
Increasing a number by a percentage is the same as multiplying by 1 + percentage/100
. So if you want to increase by 5.3%
, you multiply by 1.053
$variable *= 1.053;
Upvotes: 1