Belt_Float
This module includes convenience methods for handling float
types.
toInt
Converts a given float
to an int
.
RESJs.log(Belt.Float.toInt(1.0) === 1) /* true */
let toInt: float => int
fromInt
Converts a given int
to a float
.
RESJs.log(Belt.Float.fromInt(1) === 1.0) /* true */
let fromInt: int => float
fromString
Converts a given string
to a float
. Returns Some(float)
when the input is a number, None
otherwise.
RESJs.log(Belt.Float.fromString("1.0") === Some(1.0)) /* true */
let fromString: string => option<float>
toString
Converts a given float
to a string
. Uses the JavaScript String
constructor under the hood.
RESJs.log(Belt.Float.toString(1.0) === "1.0") /* true */
let toString: float => string
+
Addition of two float
values.
Can be opened in a module to avoid dot-notation (+.
), however this yields a shadow warning (Warning number 44) in the default configuration.
RESopen Belt.Float
Js.log(2.0 + 2.0 === 4.0) /* true */
let _: %rescript.typehole
-
Subtraction of two float
values.
Can be opened in a module to avoid dot-notation (-.
), however this yields a shadow warning (Warning number 44) in the default configuration.
RESopen Belt.Float
Js.log(2.0 - 1.0 === 1.0) /* true */
let _: %rescript.typehole
*
Multiplication of two float
values.
Can be opened in a module to avoid dot-notation (*.
), however this yields a shadow warning (Warning number 44) in the default configuration.
RESopen Belt.Float
Js.log(2.0 * 2.0 === 4.0) /* true */
let _: %rescript.typehole
/
Division of two float
values.
Can be opened in a module to avoid dot-notation (/.
), however this yields a shadow warning (Warning number 44) in the default configuration.
RESopen Belt.Float
Js.log(4.0 / 2.0 === 2.0) /* true */
let _: %rescript.typehole