floatToInt (Function)
Signature: floatToInt(x: float) -> Result<int, Error>
Description: Checked truncation toward zero: Success(n) when x is finite and inside the int range, Error for NaN, infinities and out-of-range magnitudes.
Parameters
- x (
float): The float to truncate
Returns: Result<int, Error>
Example
fn describe(x) = match floatToInt(x) {
Success { value } => toString(value)
Error { message } => message
}
print("${describe(-2.9)}\n${describe(sqrt(-1.0))}")
describe x = match floatToInt x
Success value => toString value
Error message => message
print "${describe (-2.9)}\n${describe (sqrt (-1.0))}"