File tree Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -7,13 +7,18 @@ function floor(f) {
77 return Math . floor ( f ) | 0 ;
88}
99
10+ function ceil ( f ) {
11+ return Math . ceil ( f ) | 0 ;
12+ }
13+
1014function random ( min , max ) {
1115 var f = Math . random ( ) * ( max - min | 0 ) ;
1216 return ( Math . floor ( f ) | 0 ) + min | 0 ;
1317}
1418
1519var Int = {
1620 floor : floor ,
21+ ceil : ceil ,
1722 random : random
1823} ;
1924
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ module Int = {
5757 @val external pow : (int , ~exp : int ) => int = "Math.pow"
5858 @val external sign : int => int = "Math.sign"
5959 let floor : float => int = f => f -> floor -> Core__Float .toInt
60+ let ceil : float => int = f => f -> ceil -> Core__Float .toInt
6061 let random : (int , int ) => int = (min , max ) =>
6162 floor (random () *. Core__Int .toFloat (max - min )) + min
6263}
Original file line number Diff line number Diff line change @@ -279,7 +279,6 @@ module Int: {
279279
280280 /**
281281 floor(v) returns the largest `int` less than or equal to the argument;
282- the result is pinned to the range of the `int` data type: -2147483648 to 2147483647.
283282 See [`Math.floor`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor)
284283 on MDN.
285284
@@ -289,12 +288,25 @@ module Int: {
289288 Math.Int.floor(3.7) == 3
290289 Math.Int.floor(3.0) == 3
291290 Math.Int.floor(-3.1) == -4
292- Math.Int.floor(-1.0e15) == -2147483648
293- Math.Int.floor(1.0e15) == 2147483647
294291 ```
295292 */
296293 let floor : float => int
297294
295+ /**
296+ ceil(v) returns the smallest `int` greater than or equal to the argument;
297+ See [`Math.floor`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor)
298+ on MDN.
299+
300+ ## Examples
301+
302+ ```rescript
303+ Math.Int.ceil(3.7) == 4
304+ Math.Int.ceil(3.0) == 3
305+ Math.Int.ceil(-3.1) == -3
306+ ```
307+ */
308+ let ceil : float => int
309+
298310 /**
299311 `random(minVal, maxVal)` returns a random integer number in the half-closed interval [minVal, maxVal).
300312 See [`Math.random`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random)
You can’t perform that action at this time.
0 commit comments