Hello,
I have a system which calculates a final value from the sum of several
different variables by adding the values of those variables together.
First, the variables must be multiplied by a percentage, in this case represented by a value between 0 and 1, with 0.00 being 0% and 1.00 being 100%:
<<set $VariableDifference1 to 0>>
<<set $MainValue to 100>>
<<set $PercentageValue to 0.056>>
$VariableDifference1
$MainValue
$PercentageValue
<<set $VariableDifference1 to $MainValue * $PercentageValue>>\
$VariableDifference1
$MainValue
$PercentageValue
And in this case, as you can see if you try it for yourselves,
$variableDifference1 becomes 5.6000000000000005 rather than 5.6. Due to
the nature of the system I am creating, answers regarding percentages etc
would need to be as precise and exact as possible. I am also unsure if
the actual addition side is correct or not, it only uses a fairly simple
<<set $x3 to $x1 + $x2>>
Type thing, but I know that the end result is often incorrect because to
multiply a number by a percentage I personally can't think of any way
other than multiplying it by a number with a decimal place, and I've had
this explained to me only recently by MadExile, but because of the way
the system performs calculation, it will sometimes return numbers with
multiple decimal places even if it's adding/multiplying two whole numbers
together.
To summarise, I'm in need of a method that could calculate the percentage
of a value as exactly as possible with as little margin for error as
possible. Thank you.