The best bet for this is to use Reverse Polish Notation
That way when the calulations get more complex
you won't have to worry about precedence.
A quick search in planet source code
should throw up a few examples