Skip to content

Commit 3270426

Browse files
committed
Sync docs for belt_Int.mli
1 parent 3bed2cc commit 3270426

File tree

1 file changed

+62
-2
lines changed

1 file changed

+62
-2
lines changed

jscomp/others/belt_Int.mli

+62-2
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,82 @@
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

25-
(** [`Belt.Int`]()
26-
Utililites for Int
25+
(**
26+
This module includes convenience methods for handling `int` types.
2727
*)
2828

29+
(**
30+
Converts a given `int` to a `float`.
31+
32+
```res example
33+
Js.log(Belt.Int.toFloat(1) === 1.0) /* true */
34+
```
35+
*)
2936
external toFloat: int -> float = "%identity"
3037

38+
(**
39+
Converts a given `float` to an `int`.
40+
41+
```res example
42+
Js.log(Belt.Int.fromFloat(1.0) === 1) /* true */
43+
```
44+
*)
3145
external fromFloat: float -> int = "%intoffloat"
3246

47+
(**
48+
Converts a given `string` to an `int`. Returns `Some(int)` when the input is a number, `None` otherwise.
49+
50+
```res example
51+
Js.log(Belt.Int.fromString("1") === Some(1)) /* true */
52+
```
53+
*)
3354
val fromString: string -> int option
3455

56+
(**
57+
Converts a given `int` to a `string`. Uses the JavaScript `String` constructor under the hood.
58+
59+
```res example
60+
Js.log(Belt.Int.toString(1) === "1") /* true */
61+
```
62+
*)
3563
external toString: int -> string = "String" [@@bs.val]
3664

65+
(**
66+
Addition of two `int` values. Same as the addition from `Pervasives`.
67+
68+
```res example
69+
open Belt.Int
70+
Js.log(2 + 2 === 4) /* true */
71+
```
72+
*)
3773
external ( + ) : int -> int -> int = "%addint"
3874

75+
(**
76+
Subtraction of two `int` values. Same as the subtraction from `Pervasives`.
77+
78+
```res example
79+
open Belt.Int
80+
Js.log(2 - 1 === 1) /* true */
81+
```
82+
*)
3983
external ( - ) : int -> int -> int = "%subint"
4084

85+
(**
86+
Multiplication of two `int` values. Same as the multiplication from `Pervasives`.
87+
88+
```res example
89+
open Belt.Int
90+
Js.log(2 * 2 === 4) /* true */
91+
```
92+
*)
4193
external ( * ) : int -> int -> int = "%mulint"
4294

95+
(**
96+
Division of two `int` values. Same as the division from `Pervasives`.
97+
98+
```res example
99+
open Belt.Int
100+
Js.log(4 / 2 === 2); /* true */
101+
```
102+
*)
43103
external ( / ) : int -> int -> int = "%divint"

0 commit comments

Comments
 (0)