forked from nisovin/MagicSpells
-
Notifications
You must be signed in to change notification settings - Fork 73
Expression‐exp4j
JasperLorelai edited this page Aug 11, 2025
·
1 revision
Source: exp4j
Name | Constant |
---|---|
PI |
pi or π
|
E | e |
Golden Ratio | φ |
Name | Example | Precedence |
---|---|---|
Addition | 2 + 2 |
20 |
Subtraction | 2 - 2 |
20 |
Multiplication | 2 * 2 |
30 |
Division | 2 / 2 |
30 |
Power | 2 ^ 2 |
80 |
Unary Minus & Plus (Sign Operators) | +2 - (-2) |
60 |
Modulo (remainder of division) | 2 % 2 |
30 |
Name | Function | Description |
---|---|---|
Natural logarithm (base e) | log(x) |
|
Logarithm (base 2) | log2(x) |
|
Logarithm (base 10) | log10(x) |
|
Logarithm of x + 1
|
log1p(x) |
|
Absolute value | abs(x) |
|
Cubic root | cbrt(x) |
|
Nearest lower integer | floor(x) |
|
Square root | sqrt(x) |
|
Nearest upper integer | ceil(x) |
|
Power (x ^ y ) |
pow(x, y) |
|
e^x |
exp(x) |
|
e^x - 1 |
expm1(x) |
|
Signum | signum(x) |
Returns -1 , 0 , or 1 as the value of x is negative, zero, or positive. |
Arbitrary base logarithm | logb(value, base) |
log(value) / log(base) |
Radian conversion | toradian(x) |
|
Degree conversion | todegree(x) |
Name | Function | Description |
---|---|---|
Sine | sin(x) |
|
Cosine | cos(x) |
|
Tangent | tan(x) |
|
Cotangent | cot(x) |
1 / tan(x) |
Arc cosine | acos(x) |
|
Arc sine | asin(x) |
|
Arc tangent | atan(x) |
|
Hyperbolic sine | sinh(x) |
|
Hyperbolic tangent | tanh(x) |
|
Hyperbolic cosine | cosh(x) |
|
Cosecant | csc(x) |
1 / sin(x) |
Secant | sec(x) |
1 / cos(x) |
Hyperbolic cosecant | csch(x) |
1 / sinh(x) |
Hyperbolic secant | sech(x) |
1 / cosh(x) |
Hyperbolic cotangent | coth(x) |
cosh(x) / sinh(x) |
Function | Description |
---|---|
rand(x, y) |
Generate a random number from x to y. |
prob(p, x, y) |
A random (p%) chance to return x, else return y. |
min(x, y) |
Return the minimum of x or y. |
max(x, y) |
Return the maximum of x or y. |
select(v, x, y, z) |
If v < 0 , return x, if v = 0 return y, if v > 0 return z. |