Int

This module includes convenience methods for handling int types.

-

RES
let -: (int, int) => int

Subtraction of two int values. Same as the subtraction from Pervasives.

Examples

RES
open Belt.Int 2 - 1 == 1

*

RES
let *: (int, int) => int

Multiplication of two int values. Same as the multiplication from Pervasives.

Examples

RES
open Belt.Int 2 * 2 == 4

/

RES
let /: (int, int) => int

Division of two int values. Same as the division from Pervasives.

Examples

RES
open Belt.Int 4 / 2 == 2

+

RES
let +: (int, int) => int

Addition of two int values. Same as the addition from Pervasives.

Examples

RES
open Belt.Int 2 + 2 == 4

fromFloat

RES
let fromFloat: float => int

Converts a given float to an int.

Examples

RES
Belt.Int.fromFloat(1.0) == 1

fromString

RES
let fromString: string => option<int>

Converts a given string to an int. Returns Some(int) when the input is a number, None otherwise.

Examples

RES
Belt.Int.fromString("1") == Some(1)

toFloat

RES
let toFloat: int => float

Converts a given int to a float.

Examples

RES
Belt.Int.toFloat(1) == 1.0

toString

RES
let toString: int => string

Converts a given int to a string. Uses the JavaScript String constructor under the hood.

Examples

RES
Belt.Int.toString(1) == "1"