Fct¶
| Spice | |
|---|---|
Functions¶
abs¶
| Spice | |
|---|---|
Calculate absolute value of the input
Parameters
| Name | Type | Description |
|---|---|---|
input |
Numeric |
Input number |
Returns: Numeric — Absulute value of input
max¶
| Spice | |
|---|---|
Calculate the maximum of two inputs
Parameters
| Name | Type | Description |
|---|---|---|
input1 |
Numeric |
First input |
input2 |
Numeric |
Second input |
Returns: Numeric — Maximum of inputs
min¶
| Spice | |
|---|---|
Calculate the minimum of two inputs
Parameters
| Name | Type | Description |
|---|---|---|
input1 |
Numeric |
First input |
input2 |
Numeric |
Second input |
Returns: Numeric — Minimum of inputs
trunc¶
| Spice | |
|---|---|
Truncate the number to a whole number
Parameters
| Name | Type | Description |
|---|---|---|
input |
double |
Intput number |
Returns: int — Rounding result
floor¶
| Spice | |
|---|---|
Round the input number down
Parameters
| Name | Type | Description |
|---|---|---|
input |
double |
Intput number |
Returns: int — Rounding result
ceil¶
| Spice | |
|---|---|
Round the input number up
Parameters
| Name | Type | Description |
|---|---|---|
input |
double |
Intput number |
Returns: int — Rounding result
round¶
| Spice | |
|---|---|
Round the input number to a whole number Note: 0.499999 is rounded down to 0, 0.5 is rounded up to 1.
Parameters
| Name | Type | Description |
|---|---|---|
input |
double |
Input number |
Returns: int — Rounding result
round¶
| Spice | |
|---|---|
Round the input number to the given number of decimal places Note: For 2 places 0.444 is rounded down to 0.44, 0.445 is rounded up to 0.45.
Parameters
| Name | Type | Description |
|---|---|---|
input |
double |
Input number |
places |
unsigned int |
Number of decimal places |
Returns: double
degToRad¶
| Spice | |
|---|---|
Convert degrees to radians
Parameters
| Name | Type | Description |
|---|---|---|
degrees |
double |
Input in degrees |
Returns: double — Input in radians
radToDeg¶
| Spice | |
|---|---|
Convert radians to degrees
Parameters
| Name | Type | Description |
|---|---|---|
radians |
double |
Returns: double — Input in degrees
sin¶
| Spice | |
|---|---|
Calculate the sine of the input, using the taylor series:
sin x = x - x^3/3! + x^5/5! - x^7/7! ...
Parameters
| Name | Type | Description |
|---|---|---|
x |
Numeric |
Input number |
Returns: double — Sine of input
cos¶
| Spice | |
|---|---|
Calculate the cosine of the input, using the taylor series:
cos x = 1 - x^2/2! + x^4/4! - x^6/6! ...
Parameters
| Name | Type | Description |
|---|---|---|
x |
Numeric |
Input number |
Returns: double — Cosine of input
factorial¶
| Spice | |
|---|---|
Calculate the factorial of the input
Parameters
| Name | Type | Description |
|---|---|---|
input |
WholeNumber |
Input number |
Returns: WholeNumber — Factorial of input
sqrt¶
| Spice | |
|---|---|
Calculate the square root of the input, using Heron's method. Note: For negative inputs 0.0 is returned, as the result is not a real number.
Parameters
| Name | Type | Description |
|---|---|---|
x |
double |
Input number |
Returns: double — Square root of input
cbrt¶
| Spice | |
|---|---|
Calculate the cube root of the input, using Newton's method.
Parameters
| Name | Type | Description |
|---|---|---|
x |
double |
Input number |
Returns: double — Cube root of input
hypot¶
| Spice | |
|---|---|
Calculate the length of the hypotenuse of a right-angled triangle from its legs.
Parameters
| Name | Type | Description |
|---|---|---|
a |
double |
Length of the first leg |
b |
double |
Length of the second leg |
Returns: double — Length of the hypotenuse
exp¶
| Spice | |
|---|---|
Calculate e raised to the power of the input, using the taylor series:
exp x = 1 + x + x^2/2! + x^3/3! ...
Parameters
| Name | Type | Description |
|---|---|---|
x |
double |
Input number |
Returns: double — e raised to the power of input
ln¶
| Spice | |
|---|---|
Calculate the natural logarithm (base e) of the input.
The input is range reduced via e, before applying the series:
ln x = 2 * (t + t^3/3 + t^5/5 ...) with t = (x-1)/(x+1)
Note: For inputs <= 0 the result 0.0 is returned, as the result is not a real number.
Parameters
| Name | Type | Description |
|---|---|---|
x |
double |
Input number |
Returns: double — Natural logarithm of input
log2¶
| Spice | |
|---|---|
Calculate the binary logarithm (base 2) of the input.
Parameters
| Name | Type | Description |
|---|---|---|
x |
double |
Input number |
Returns: double — Binary logarithm of input
log10¶
| Spice | |
|---|---|
Calculate the common logarithm (base 10) of the input.
Parameters
| Name | Type | Description |
|---|---|---|
x |
double |
Input number |
Returns: double — Common logarithm of input
log¶
| Spice | |
|---|---|
Calculate the logarithm of the input to an arbitrary base.
Parameters
| Name | Type | Description |
|---|---|---|
x |
double |
Input number |
base |
double |
Logarithm base |
Returns: double — Logarithm of input to the given base
pow¶
| Spice | |
|---|---|
Raise the base to an integer power, using exponentiation by squaring.
Parameters
| Name | Type | Description |
|---|---|---|
base |
double |
Base number |
exponent |
int |
Integer exponent |
Returns: double — base raised to the power of exponent
pow¶
| Spice | |
|---|---|
Raise the base to an arbitrary power, computed as exp(exponent * ln(base)). Note: For a negative base only integer exponents are defined, otherwise 0.0 is returned.
Parameters
| Name | Type | Description |
|---|---|---|
base |
double |
Base number |
exponent |
double |
Exponent |
Returns: double — base raised to the power of exponent
tan¶
| Spice | |
|---|---|
Calculate the tangent of the input (in degrees).
Parameters
| Name | Type | Description |
|---|---|---|
x |
Numeric |
Input number in degrees |
Returns: double — Tangent of input
atan¶
| Spice | |
|---|---|
Calculate the arc tangent of the input, returning the result in degrees.
The input is range reduced using the half-angle identity, before applying the series:
atan x = x - x^3/3 + x^5/5 - x^7/7 ...
Parameters
| Name | Type | Description |
|---|---|---|
x |
double |
Input number |
Returns: double — Arc tangent of input in degrees
atan2¶
| Spice | |
|---|---|
Calculate the arc tangent of y/x, returning the result in degrees. Unlike atan, the signs of both arguments are used to determine the correct quadrant.
Parameters
| Name | Type | Description |
|---|---|---|
y |
double |
Ordinate (y-coordinate) |
x |
double |
Abscissa (x-coordinate) |
Returns: double — Arc tangent of y/x in degrees
asin¶
| Spice | |
|---|---|
Calculate the arc sine of the input, returning the result in degrees. Note: For inputs outside of [-1, 1] the result is clamped to +/- 90 degrees.
Parameters
| Name | Type | Description |
|---|---|---|
x |
double |
Input number in range [-1, 1] |
Returns: double — Arc sine of input in degrees
acos¶
| Spice | |
|---|---|
Calculate the arc cosine of the input, returning the result in degrees. Note: For inputs outside of [-1, 1] the result is clamped to [0, 180] degrees.
Parameters
| Name | Type | Description |
|---|---|---|
x |
double |
Input number in range [-1, 1] |
Returns: double — Arc cosine of input in degrees
sinh¶
| Spice | |
|---|---|
Calculate the hyperbolic sine of the input.
Parameters
| Name | Type | Description |
|---|---|---|
x |
double |
Input number |
Returns: double — Hyperbolic sine of input
cosh¶
| Spice | |
|---|---|
Calculate the hyperbolic cosine of the input.
Parameters
| Name | Type | Description |
|---|---|---|
x |
double |
Input number |
Returns: double — Hyperbolic cosine of input
tanh¶
| Spice | |
|---|---|
Calculate the hyperbolic tangent of the input.
Parameters
| Name | Type | Description |
|---|---|---|
x |
double |
Input number |
Returns: double — Hyperbolic tangent of input
gcd¶
| Spice | |
|---|---|
Calculate the greatest common divisor of two inputs, using the Euclidean algorithm.
Parameters
| Name | Type | Description |
|---|---|---|
input1 |
WholeNumber |
First input |
input2 |
WholeNumber |
Second input |
Returns: WholeNumber — Greatest common divisor of the inputs
lcm¶
| Spice | |
|---|---|
Calculate the least common multiple of two inputs.
Parameters
| Name | Type | Description |
|---|---|---|
input1 |
WholeNumber |
First input |
input2 |
WholeNumber |
Second input |
Returns: WholeNumber — Least common multiple of the inputs
clamp¶
| Spice | |
|---|---|
Clamp the value to the inclusive range [minValue, maxValue].
Parameters
| Name | Type | Description |
|---|---|---|
value |
Numeric |
Input value |
minValue |
Numeric |
Lower bound |
maxValue |
Numeric |
Upper bound |
Returns: Numeric — Clamped value
almostEqual¶
| Spice | |
|---|---|
Check if two floating point numbers are approximately equal within a default epsilon.
Parameters
| Name | Type | Description |
|---|---|---|
input1 |
double |
First input |
input2 |
double |
Second input |
Returns: bool — true if the inputs are approximately equal
almostEqual¶
| Spice | |
|---|---|
Check if two floating point numbers are approximately equal within the given epsilon.
Parameters
| Name | Type | Description |
|---|---|---|
input1 |
double |
First input |
input2 |
double |
Second input |
epsilon |
double |
Maximum allowed absolute difference |
Returns: bool — true if the inputs are approximately equal