Float
This module includes convenience methods for handling float types.
toInt
let toInt: float => intfromInt
let fromInt: int => floatfromString
let fromString: string => option<float>Converts a given string to a float. Returns Some(float) when the input is a number, None otherwise.
Examples
RESCRIPTBelt.Float.fromString("1.0") == Some(1.0)
toString
let toString: float => stringConverts a given float to a string. Uses the JavaScript String constructor under the hood.
Examples
RESCRIPTBelt.Float.toString(1.0) == "1"
+
let +: (float, float) => floatAddition 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.
Examples
RESCRIPTopen Belt.Float
2.0 + 2.0 == 4.0
-
let -: (float, float) => floatSubtraction 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.
Examples
RESCRIPTopen Belt.Float
2.0 - 1.0 == 1.0
*
let *: (float, float) => floatMultiplication 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.
Examples
RESCRIPTopen Belt.Float
2.0 * 2.0 == 4.0
/
let /: (float, float) => float