Extra Functions and Operators¶
- Table of contents
- Extra Functions and Operators
There are a number of extra functions and operators included in this version of
exp4j, non of this are enabled by default, they are in the
Aside from the arithmetic operators several comparison operators are included:
Please note that since
exp4j itself has no concept of
boolean, the results given by all of the comparison operators will be
false. Let it be noted that due to rounding, equality operators use a radix in which they consider numbers to be "equal", that is:
b be two real numbers,
a == b will evaluate to
true if and only if the distance between
dist(a, b) := abs(a - b)) is less or equal than
Operator precedence is altered when using the comparison operators, the new precedence is:
FIRST-> * / % - + > >= < <= ¬ & | == != <-LAST ----- --- --------- - - - ----- ^^^ The dashes indicate groups with the same precedence
Even though we have boolean operators, there are also a number of boolean functions that can be used (some people prefer functions)
and(a, b): Logical and equivalent to
a & b
or(a, b): Logical or equivalent to
a | b
xor(a, b): Exclusive or
nand(a, b): equivalent to
¬(a & b)
nor(a, b): equivalent to
¬(a | b)
xnor(a, b): Negated exclusive or
not(a): equivalent to
true(): true value
1.0(true is actually any value different than zero, but this is the value returned by comparison operators, boolean operators and boolean functions.
false(): false value
if(e, v_true, v_false): Branches the formula, it will be evaluated as
e == true()and
e == false()
equals(a, b): Equivalent to
a == b, so the same conditions apply.
isNan(a): Tells if a value is
Not A Number
min(x, y): Returns the smallest (closest to negative infinity) of two numbers.
max(x, y): Returns the largest (closest to positive infinity) of two numbers.
lcm(x, y): Returns the Least Common Multiple of two numbers.
gcd(x, y): Returns the Greatest Common Divisor of two numbers.
round(x): Returns the closest integer of
deg2rad(x): Returns the value of
xexpressed in radians.
rad2deg(x): Returns the value of
xexpressed in degrees.
sinc(t): Cardinal sine of
t(not normalized), equivalent to
triangle(t): Triangle wave
sawtooth(t): Sawtooth wave
heavyside(t): Heavyside Step function
rectangle(t, X, Y): Rectangular function
inf(): Retrieves the value of
Expression based functions¶
- It's now possible to create expression based functions! See: Expression Based Functions