Trunc v0.1.0
Rounds toward zero.
Package: Math
Signature
func Trunc(x: float64) -> float64;
func Trunc(x: float32) -> float32;
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 / float32 | The value to round. |
Returns
The integer part of x, discarding any fractional part, still represented
as a floating-point number. Trunc(-0.4) keeps its sign and is -0.0.
Infinities and NaNs pass through unchanged.
Example
import Math::Trunc;
func Main() -> int {
let a = Trunc(3.9); // 3.0
let b = Trunc(-3.9); // -3.0
return 0;
}