rhai/doc/src/language/num-fn.md

34 lines
1.8 KiB
Markdown
Raw Normal View History

2020-06-20 06:06:17 +02:00
Numeric Functions
================
{{#include ../links.md}}
Integer Functions
----------------
2020-06-27 04:43:57 +02:00
The following standard functions (defined in the [`BasicMathPackage`][packages] but excluded if using a [raw `Engine`])
2020-06-20 06:06:17 +02:00
operate on `i8`, `i16`, `i32`, `i64`, `f32` and `f64` only:
2020-06-25 13:19:16 +02:00
| Function | Description |
| ------------ | --------------------------------------------------------------- |
| `abs` | absolute value |
| `sign` | returns -1 if the number is negative, +1 if positive, 0 if zero |
| [`to_float`] | converts an integer type to `f64` |
2020-06-20 06:06:17 +02:00
Floating-Point Functions
-----------------------
2020-06-27 04:43:57 +02:00
The following standard functions (defined in the [`BasicMathPackage`][packages] but excluded if using a [raw `Engine`])
2020-06-20 06:06:17 +02:00
operate on `f64` only:
| Category | Functions |
| ---------------- | --------------------------------------------------------------------- |
| Trigonometry | `sin`, `cos`, `tan`, `sinh`, `cosh`, `tanh` in degrees |
| Arc-trigonometry | `asin`, `acos`, `atan`, `asinh`, `acosh`, `atanh` in degrees |
| Square root | `sqrt` |
| Exponential | `exp` (base _e_) |
| Logarithmic | `ln` (base _e_), `log10` (base 10), `log` (any base) |
| Rounding | `floor`, `ceiling`, `round`, `int`, `fraction` methods and properties |
| Conversion | [`to_int`] |
| Testing | `is_nan`, `is_finite`, `is_infinite` methods and properties |