most likely it is because you need to use parenthesis in your math logic
you need to enable that in the app settings (under versions)
then you may also want to break down the calculation into steps using custom events to process each part of the logic. you could either hold just the number in the event or update the database record in a field.
you could also use the math plugin for more complex math operations if needed.
my guess - without seeing your calculations - is that how you are applying the percentages is throwing the calc off