Belt_Int
This module includes convenience methods for handling int
types.
toFloat
Converts a given int
to a float
.
RESJs.log(Belt.Int.toFloat(1) === 1.0) /* true */
let toFloat: int => float
fromFloat
Converts a given float
to an int
.
RESJs.log(Belt.Int.fromFloat(1.0) === 1) /* true */
let fromFloat: float => int
fromString
Converts a given string
to an int
. Returns Some(int)
when the input is a number, None
otherwise.
RESJs.log(Belt.Int.fromString("1") === Some(1)) /* true */
let fromString: string => option<int>
toString
Converts a given int
to a string
. Uses the JavaScript String
constructor under the hood.
RESJs.log(Belt.Int.toString(1) === "1") /* true */
let toString: int => string
+
Addition of two int
values. Same as the addition from Pervasives
.
RESopen Belt.Int
Js.log(2 + 2 === 4) /* true */
let _: %rescript.typehole
-
Subtraction of two int
values. Same as the subtraction from Pervasives
.
RESopen Belt.Int
Js.log(2 - 1 === 1) /* true */
let _: %rescript.typehole
*
Multiplication of two int
values. Same as the multiplication from Pervasives
.
RESopen Belt.Int
Js.log(2 * 2 === 4) /* true */
let _: %rescript.typehole
/
Division of two int
values. Same as the division from Pervasives
.
RESopen Belt.Int
Js.log(4 / 2 === 2); /* true */
let _: %rescript.typehole