I am using the NSExpression function to evaluate strings as a numerical equation.
One problem that I have encountered is; when you have a division “/” operation in the string you are calculating NSExpression does not convert the answer into a float point (double) unless a decimal value is given.
Ex. ( 1.0 / 2 ) = 0.5
But ( 1 / 2 ) = 0
I wonder if there is a simple solution to this problem or if I would have to write a loop that inserts “.0” when it detects a division with no other decimals.
I have tried making a loop like this with little success, so if there is a better solution or someone has a loop structure to solve this problem, it would be greatly appreciated.
Thanks,
Regards.
Have you considered DDMathParser? From what I found it does a lot of work for you…