rhai/doc/src/language/num-fn.md
2020-06-27 10:43:57 +08:00

1.8 KiB

Numeric Functions

{{#include ../links.md}}

Integer Functions

The following standard functions (defined in the [BasicMathPackage][packages] but excluded if using a [raw Engine]) operate on i8, i16, i32, i64, f32 and f64 only:

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

Floating-Point Functions

The following standard functions (defined in the [BasicMathPackage][packages] but excluded if using a [raw Engine]) 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