Int
This module includes convenience methods for handling int types.
toFloat
RESCRIPT
let toFloat: int => floatfromFloat
RESCRIPT
let fromFloat: float => intfromString
RESCRIPT
let fromString: string => option<int>Converts a given string to an int. Returns Some(int) when the input is a number, None otherwise.
Examples
RESCRIPTJs.log(Belt.Int.fromString("1") === Some(1)) /* true */
toString
RESCRIPT
let toString: int => stringConverts a given int to a string. Uses the JavaScript String constructor under the hood.
Examples
RESCRIPTJs.log(Belt.Int.toString(1) === "1") /* true */
+
RESCRIPT
let +: (int, int) => intAddition of two int values. Same as the addition from Pervasives.
Examples
RESCRIPTopen Belt.Int
Js.log(2 + 2 === 4) /* true */
-
RESCRIPT
let -: (int, int) => intSubtraction of two int values. Same as the subtraction from Pervasives.
Examples
RESCRIPTopen Belt.Int
Js.log(2 - 1 === 1) /* true */
*
RESCRIPT
let *: (int, int) => intMultiplication of two int values. Same as the multiplication from Pervasives.
Examples
RESCRIPTopen Belt.Int
Js.log(2 * 2 === 4) /* true */
/
RESCRIPT
let /: (int, int) => int