Reputation: 393
How to divide two numbers but keep the decimal point.
Also I need to turn the decimal point into a percentage...ie .25 to 25%
tried $set ($percent = $a / $b) In this case $a = 10, $b = 40.
#set($percent = $totalSponsored / $totalAppliesAllJobs)
Upvotes: 1
Views: 420
Reputation: 11
#set($percent = (($totalSponsored*1.0) / ($totalAppliesAllJobs*1.0))*100)
In the above way it will become decimal/decimal which gives the ratio. Multiple it with 100 for percentage.
Upvotes: 0
Reputation: 39
double result = (double) number1 / (double) number2 * 100.0
The result
variable now contains the percentage.
Upvotes: -1