Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Float.mo
Original file line number Diff line number Diff line change
Expand Up @@ -471,14 +471,18 @@ module {
/// ```
public let fromInt64 : Int64 -> Float = Prim.int64ToFloat;

/// Conversion to `Int`.
/// Conversion to `Int` by truncating the decimal places of the float,
/// equivalent to `Float.toInt(Float.trunc(f))`.
/// Truncation rounds toward zero: the fractional part is dropped regardless of sign.
///
/// Traps for `inf`, `-inf`, and `NaN`.
///
/// Example:
/// ```motoko
/// import Float "mo:base/Float";
///
/// Float.toInt(1.9) // => +1 (truncates, does not round up)
/// Float.toInt(-1.9) // => -1 (truncates toward zero, not toward -inf)
/// Float.toInt(1.2e6) // => +1_200_000
/// ```
public let toInt : Float -> Int = Prim.floatToInt;
Expand Down