GCMathParser is a free class that you can use in applications that need a way to deal with mathematical expressions input by the user.
GCMathParser accepts an NSString consisting of a well-formed mathematical expression, evaluates it, and returns the result. It supports arbitrary named variables, so it is also perfect for graph plotting applications.
Supported functions and operators:
· Basic operators: +, -, * (multiply) and / (divide)
· Mod operator: %
· Exponentiation operator: ^
· Negation: unary -
· Assignment: =
· Log functions: log(), log2(), ln(), exp()
· Transcendental functions: sin(), cos(), tan(), asin(), acos(), atan(), sinh(), cosh(), tanh(), asinh(), acosh(), atanh()
· Square root function: sqrt()
· Rounding functions: ceil(), floor(), round(), trunc(), rint(), near()
· Angular conversion functions: dtor(), rtod()
· Absolute value function: abs()
· Constants: pi
Requirements:
· Xcode