Вы находитесь на странице: 1из 4

Welcome:

DDMathParser is a software that allow to parse mathematics strings expression and calculate them,
written by davedelong
DDMath Tweak is a tweak that helps to communicate between the stock iOS keyboard and DDMathParser logick this
features adds new layer to the keyboard,making it more advanced in its' capabilities
any features request about mathematical functions should go to the Developer of DDMath Parser,not to me.
DDMath Tweak:
DDMath Tweak was designed to be very simple , The general used is,
you type a math expression, and at the end of it Long press on the equal sign '= ' to evaluate the expression.
There are two modes in the tweak which can be configured in the settings app
1. NOSpace - Mode:
In this mode:
you type your mathematical expression without any space between the expressions members,
The advantage in this mode is, you can type normal strings in same line of the math expression
Restrictions for this mode:
no space is allowed between the end of the expression and the caret/cursor position when long pressing the = sign
to evaluate the expression,this because the math expression is taken relatively to the caret position,
DDMath tweak check the position of the caret and expects the math expression to be next to the caret position in this
mode,if space is entered the math expression is considered as nothing.
2.Line - Mode:
In this mode:
only math expressions is allowed in a line,no normal strings is allowed.
Restrictions for this mode:
None.
to calculate the expression "2+4*(18/3)"
examples:
first you type: 2+4*(18/3) and after the closing parenthesis Long press on the equal sign '='.
To calculate the expression "2*2*2"
Option one: 2**3
Option two: Pow(2,3)
For more functions see the function list below.
NOTE:
you don't have to retype math expression in order to change some parameters,
just go to the position of the math expression in your text,place the caret next to it,and long press on the equal (=) sign.
oi va 04 anx! 2013 16:28

DDMath Parser
Available Functions and General Documentation:
below you will find information and summary of functions and used instructions taken from the
project site,
(project site is included at the end of the document)
Standard Operators
Operator Function Description
+ add addition and unary positive
- or subtract and negate subtraction and negation
* or multiply multiplication
/ or divide division
% mod or percent modulus or a percentage of a
value
! factorial factorial
** pow exponentiation
or dtor converts the value to radians
Bitwise Operators
& and bitwise and
| or bitwise or
^ xor bitwise xor
~ not bitwise not
<< lshift bitwise left shift
>> rshift bitwise right shift
Comparison Operators
== or = l_eq equal
!= l_neq not equal
< l_lt less than
> l_gt greater than
<= or l_ltoe less than or equal
>= or l_gtoe greater than or equal
Logical Operators
&& or l_and logical and
|| or l_or logical or
! or l_not logical not
Considerations
The Degree Operator:
The degree operator () is interesting. Because all of the trigonometric functions require their
parameters to be passed in radians,
the degree operator will convert its operand into radians. Thus, 45 is equivalent to dtor(45).
The % Sign
The % sign is usually interpreted as the modulo operator. However,
DDMathParser.h defines a compile-time switch (DD_INTERPRET_PERCENT_SIGN_AS_MOD) that
allows you to change it to be interpreted as a percentage.
When the percent sign is interpreted as modulo, then:
10 % 3
... evaluates to 1 (the remainder after 10 is divided by 3). However, if you flip the switch to make

... evaluates to 1 (the remainder after 10 is divided by 3). However, if you flip the switch to make
the % sign be a percentage, then you can now do:
250 + 10%
By default, % is usually shorthand for "/100". In other words, 42% becomes 42/100, or 0.42.
However, if the % term is the right hand sign of either a subtraction or addition operation (such as
in "250 + 10%"),
then the percent is evaluated as a percentage of the left-hand side (i.e. "250 plus 10% of 250").
If you choose to interpret the percent sign as the modulo operator, you can still request a
percentage by using the function name directly:
(10 % 3) + percent(50) = 1.5
The question arises: why are these mutually exclusive? It's because of a limitation in the design of
the tokenizer.
When an operator is encountered that is ambiguous (ex: ! can be both factorial and logical not),
it is disambiguated exclusively by the token that precedes it. Since both modulo and percent are
preceded by identical things (usually a number),
there's currently no way to disambiguate whether % refers to a modulo operation or a percent
operation.
Therefore, the distinction must be made at compile-time.
Logical Values
The comparison and logical operators both return a boolean value. During evaluation,
that boolean value is strictly interpreted as either 0 (false) or 1 (true).
For example, @"41 + (1 && 1)" is literally 41 + true, but is evaluated as 42.
On the same note, the operands to the logical operators are also interpreted as booleans (using -
[NSNumber boolValue]).
Factorial and Logical Not
Differentiating between factorial (!) and a logical not (!) is difficult. A ! is interpreted as a logical not
if:
it is the first token
it is preceded by a binary operator
it is preceded by a right associative unary operator
Otherwise it is treated as a factorial. A token is always treated as a logical not (for obvious
reasons).
Parentheses and Associativity
For simplification in dealing with implicit multiplication, an opening parenthesis is considered a
right associative unary operator,
and a closing parenthesis is considered a left associative unary operator.
Standard Functions:
sum() - returns a sum of the passed parameters
count() - returns the number of passed parameters
min() - returns the minimum of the passed parameters
max() - returns the maximum of the passed parameters
median() - returns the median of the passed parameters
stddev() - returns the standard deviation of the passed parameters
average() - returns the average of the passed parameters
random() - returns a random integer. Can take 0, 1, or 2 parameters. The first parameter (if given)
is the lower bound of the random integer.
The second parameter (if given) is the upper bound of the random integer.
nthroot() - returns the nth root of a number. For example, nthroot(27,3) returns the cube root of
27, or 3.

Functions that take 1 parameter:
sqrt() - returns the square root of the passed parameter
log() - returns the base 10 log of the passed parameter
ln() - returns the base e log of the passed parameter
log2() - returns the base 2 log of the passed parameter
exp() - returns e raised to the power of the passed parameter
ceil() - returns the passed parameter rounded up
floor() - returns the passed parameter rounded down
The trigonometric functions:
sin(), cos(), tan()
Their inverses (asin, acos, atan)
Their reciprocals (csc, sec, cotan)
The reciprocals of the inverses (acsc, asec, acotan)
The hyperbolic variations of all the above functions (sinh, cosh, tanh, asinh, acosh, atanh, csch,
sech, cotanh, acsch, asech, acotanh)
The versine functions (versin, vercosin, coversin, covercosin, haversin, havercosin, hacoversin,
hacovercosin, exsec, excsc, crd)
dtor() - converts the passed parameter from degrees to radians
rtod() - converts the passed parameter from radians to degrees
Functions that take no parameters ("constant functions"):
phi() - returns the value of (the Golden Ratio). Also recognized as ()
pi() - returns the value of . Also recognized as ()
pi_2() - returns the value of /2
pi_4() - returns the value of /4
tau() - returns the value of . Also recognized as ()
sqrt2() - returns the value of the square root of 2
e() - returns the value of e
log2e() - returns the value of the log base 2 of e
log10e() - returns the value of the log base 10 of e
ln2() - returns the value of the log base e of 2
ln10() - returns the value of the log base e of 10
Aliases
Functions can also have aliases. For example, the following are equivalent:
average(1,2,3)
avg(1,2,3)
mean(1,2,3)
FOR MORE INFO PLEASE SEE THE DDMATH PARSER WIKI:
https://github.com/davedelong/DDMathParser/wiki/Built-in-Functions

Вам также может понравиться