This will calculate exact decimal values to any decimal places you want. Just plug in dividend, divisor, and decimal places and $result variable will be set to the answer.
# Preforms calculation with decimal points
# dividend / divisor = quotient.decimal = result
:local dividend 3
:local divisor 11
:local decimalplaces 3
# Math Calculation here
:local quotient 0
:local remainder 0
:local result 0
:local decimal 0
:set quotient ($dividend / $divisor)
:if ($quotient = 0) do={
:set dividend [:tonum ($dividend . "0")]
}
:set remainder ($dividend - ($divisor * $quotient))
:if ($remainder > 0) do={
:local tmpremainder [:tonum ($remainder . "0")]
:for x from=1 to=$decimalplaces do={
:local tmpdecimal [:tonum ($tmpremainder / $divisor)]
:set decimal [:tonum ($decimal . $tmpdecimal)]
:set tmpremainder [:tonum (($tmpremainder - ($tmpdecimal * $divisor)) . "0")]
}
:set result ($quotient . "." . $decimal)
} else={
:set result $quotient
}
# END Math Calculation here
:put ($dividend . " / " . $divisor . " = " . $result)
Hope this helps.