Std::Math
Mathematical constants and floating-point functions.
Module: Std::Math
Every function is provided for both float64 and float32. Pass float64 arguments to get a float64 result, or float32 for a float32 result.
rux
import Std::Math;
import Std::Io::PrintLine;
func Main() -> int {
PrintLine(Math::Sqrt(2.0)); // 1.4142135623730951
PrintLine(Math::Pow(2.0, 10.0)); // 1024
return 0;
}Constants
| Name | Type | Value |
|---|---|---|
Pi | float64 | 3.14159265358979323846 |
E | float64 | 2.71828182845904523536 |
rux
let circumference = 2.0 * Math::Pi * radius;Functions
Trigonometry
| Function | Description |
|---|---|
Sin | Sine of an angle in radians. |
Cos | Cosine of an angle in radians. |
Tan | Tangent of an angle in radians. |
Powers and roots
| Function | Description |
|---|---|
Sqrt | Square root. |
Pow | Raise a base to an exponent. |
Rounding and sign
| Function | Description |
|---|---|
Abs | Absolute value. |
Floor | Round down to an integer value. |
Ceil | Round up to an integer value. |
Round | Round to the nearest integer value. |
Integer
| Function | Description |
|---|---|
Add | Integer addition (primarily internal). |