-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathCore__Math.resi
839 lines (682 loc) · 21.6 KB
/
Core__Math.resi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
/* Copyright (C) 2015-2016 Bloomberg Finance L.P.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* In addition to the permissions granted to you by the LGPL, you may combine
* or link a "work that uses the Library" with a publicly distributed version
* of this file to produce a combined library or application, then distribute
* that combined work under the terms of your choosing, with no requirement
* to comply with the obligations normally placed on you by section 4 of the
* LGPL version 3 (or the corresponding section of a later version of the LGPL
* should you choose to use a later version).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/***
Functions for interacting with JavaScript Math.
See: [`Math`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math).
*/
/**
Mathematical Constants
*/
module Constants: {
/**
`Math.Constants.e` returns Euler's number, ≈ 2.718281828459045.
See [`Math.E`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/E) on MDN.
## Examples
```rescript
Math.Constants.e
```
*/
@val
external e: float = "Math.E"
/**
`Math.Constants.ln2` returns Natural logarithm of 2, ≈ 0.6931471805599453.
See [`Math.LN2`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LN2) on MDN.
## Examples
```rescript
Math.Constants.LN2
```
*/
@val
external ln2: float = "Math.LN2"
/**
`Math.Constants.ln10` returns Natural logarithm of 10, ≈ 2.302585092994046.
See [`Math.LN10`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LN10) on MDN.
## Examples
```rescript
Math.Constants.ln10
```
*/
@val
external ln10: float = "Math.LN10"
/**
`Math.Constants.log2e` returns Base 2 logarithm of E, ≈ 1.4426950408889634.
See [`Math.LOG2E`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LOG2E) on MDN.
## Examples
```rescript
Math.Constants.log2e
```
*/
@val
external log2e: float = "Math.LOG2E"
/**
`Math.Constants.log10e` returns Base 10 logarithm of E, ≈ 0.4342944819032518.
See [`Math.LOG10E`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LOG10E) on MDN.
## Examples
```rescript
Math.Constants.log10e
```
*/
@val
external log10e: float = "Math.LOG10E"
/**
`Math.Constants.pi` returns Pi - ratio of the circumference to the diameter
of a circle, ≈ 3.141592653589793.
See [`Math.PI`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/PI) on MDN.
## Examples
```rescript
Math.Constants.pi
```
*/
@val
external pi: float = "Math.PI"
/**
`Math.Constants.sqrt1_2` returns Square root of 1/2, ≈ 0.7071067811865476.
See [`Math.SQRT1_2`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/SQRT1_2) on MDN.
## Examples
```rescript
Math.Constants.sqrt1_2
```
*/
@val
external sqrt1_2: float = "Math.SQRT1_2"
/**
`Math.Constants.e` returns Absolute value for integer argument.
See [`Math.abs`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs) on MDN.
## Examples
```rescript
Math.Constants.sqrt2
```
*/
@val
external sqrt2: float = "Math.SQRT2"
}
/**
Provide Math utilities for `int`
*/
module Int: {
/**
`abs(v)` returns absolute value of `v`.
See [`Math.abs`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs) on MDN.
## Examples
```rescript
Math.Int.abs(-2) // 2
Math.Int.abs(3) // 3
```
*/
@val
external abs: int => int = "Math.abs"
/**
`clz32(v)` returns the number of leading zero bits of the argument's 32 bit
int representation.
See [`Math.clz32`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32) on MDN.
## Examples
```rescript
// 00000000000000000000000000000001
Math.Int.clz32(1) // 31
// 00000000000000000000000000000100
Math.Int.clz32(4) // 29
```
*/
@val
external clz32: int => int = "Math.clz32"
/**
`imul(a, b)` returns 32-bit integer multiplication. Use this only when you
need to optimize performance of multiplication of numbers stored as 32-bit
integers.
See [`Math.imul`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul) on MDN.
## Examples
```rescript
Math.Int.imul(3, 4) // 12
Math.Int.imul(-5, 12) // 60
```
*/
@val
external imul: (int, int) => int = "Math.imul"
/**
`min(a, b)` returns the minimum of its two integer arguments.
See [`Math.min`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min) on MDN.
## Examples
```rescript
Math.Int.min(1, 2) // 1
Math.Int.min(-1, -2) // -2
```
*/
@val
external min: (int, int) => int = "Math.min"
/**
`minMany(arr)` returns the minimum of the integers in the given array `arr`.
Returns `Infinity` if `arr` is empty.
See [`Math.min`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min) on MDN.
## Examples
```rescript
Math.Int.minMany([1, 2]) // 1
Math.Int.minMany([-1, -2]) // -2
Math.Int.minMany([]) // 0
```
*/
let minMany: array<int> => int
/**
`max(a, b)` returns the maximum of its two integer arguments.
See [`Math.max`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max) on MDN.
## Examples
```rescript
Math.Int.max(1, 2) // 2
Math.Int.max(-1, -2) // -1
```
*/
@val
external max: (int, int) => int = "Math.max"
/**
`maxMany(arr)` returns the maximum of the integers in the given array `arr`.
Returns `Infinity` if `arr` is empty.
See [`Math.max`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max) on MDN.
## Examples
```rescript
Math.Int.maxMany([1, 2]) // 2
Math.Int.maxMany([-1, -2]) // -1
Math.Int.maxMany([]) // 0
```
*/
let maxMany: array<int> => int
/**
`pow(a, ~exp)` raises the given base `a` to the given exponent `exp`.
See [`Math.pow`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow) on MDN.
## Examples
```rescript
Math.Int.pow(2, ~exp=4) // 16
Math.Int.pow(3, ~exp=4) // 81
```
*/
@val
external pow: (int, ~exp: int) => int = "Math.pow"
/**
`sign(v)` returns the sign of its integer argument: `-1` if negative, `0` if
zero, `1` if positive.
See [`Math.sign`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign) on MDN.
## Examples
```rescript
Math.Int.sign(3) // 1
Math.Int.sign(-3) // 1
Math.Int.sign(0) // 0
```
*/
@val
external sign: int => int = "Math.sign"
}
/**
`abs(v)` returns absolute value of `v`.
See [`Math.abs`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs) on MDN.
## Examples
```rescript
Math.abs(-2.0) // 2.0
Math.abs(3.0) // 3.0
```
*/
@val
external abs: float => float = "Math.abs"
/**
`acos(v)` returns arccosine (in radians) of argument `v`, returns `NaN` if the
argument is outside the range [-1.0, 1.0].
See [`Math.acos`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acos) on MDN.
## Examples
```rescript
Math.acos(-1) // 3.141592653589793
Math.acos(-3)->Float.isNaN // true
```
*/
@val
external acos: float => float = "Math.acos"
/**
`acosh(v)` returns the inverse hyperbolic arccosine (in radians) of argument `v`,
returns `NaN` if the argument is less than `1.0`.
See [`Math.acosh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acosh) on MDN.
## Examples
```rescript
Math.acosh(1) // 0.0
Math.acosh(0.5)->Float.isNaN // true
```
*/
@val
external acosh: float => float = "Math.acosh"
/**
`asin(v)` returns the inverse sine (in radians) of argument `v`, returns `NaN`
if the argument `v` is outside the range [-1.0, 1.0].
See [`Math.asin`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asin) on MDN.
## Examples
```rescript
Math.asin(-1.0) // -1.5707963267948966
Math.asin(-2.0)->Float.isNaN // true
```
*/
@val
external asin: float => float = "Math.asin"
/**
`asinh(v)` returns the inverse hyperbolic sine of argument `v`.
See [`Math.asinh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asinh) on MDN.
## Examples
```rescript
Math.asinh(-1) // -0.881373587019543
Math.asinh(-0) // -0.0
```
*/
@val
external asinh: float => float = "Math.asinh"
/**
`atan(v)` returns the inverse tangent (in radians) of argument `v`.
See [`Math.atan`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan) on MDN.
## Examples
```rescript
Math.atan(-0.0) // -0.0
Math.atan(0.0) // 0.0
Math.atan(1) // 0.7853981633974483
```
*/
@val
external atan: float => float = "Math.atan"
/**
`atanh(v)` returns the invert hyperbolic tangent of argument `v`. Returns `NaN`
if the argument `v` is is outside the range [-1.0, 1.0] and `Infinity` if `v`
is `-1.0` or `1.0`.
See [`Math.atanh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atanh) on MDN.
## Examples
```rescript
Math.atanh(-2.0)->Float.isNaN // true
Math.atanh(-1.0)->Float.isFinite // false
Math.atanh(-0.0) // -0.0
Math.atanh(0.0) // 0.0
Math.atanh(0.5) // 0.5493061443340548
```
*/
@val
external atanh: float => float = "Math.atanh"
/**
`atan2(~y, ~x)` returns the angle (in radians) of the quotient `y /. x`. It is
also the angle between the *x*-axis and point (*x*, *y*).
See [`Math.atan2`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan2) on MDN.
## Examples
```rescript
Math.atan2(~y=0.0, ~x=10.0) == 0.0
Math.atan2(~x=5.0, ~y=5.0) == Math.Constants.pi /. 4.0
Math.atan2(~x=90.0, ~y=15.0) // 1.4056476493802699
Math.atan2(~x=15.0, ~y=90.0) // 0.16514867741462683
```
*/
@val
external atan2: (~y: float, ~x: float) => float = "Math.atan2"
/**
`cbrt(v)` returns the cube root of argument `v`.
See [`Math.cbrt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt) on MDN.
## Examples
```rescript
Math.cbrt(-1.0) // -1.0
Math.cbrt(-0.0) // -0.0
Math.cbrt(0.0) // 0.0
```
*/
@val
external cbrt: float => float = "Math.cbrt"
/**
`ceil(v)` returns the smallest integral value greater than or equal to the
argument `v`. The result is a `float` and is not restricted to the `int` data
type range.
See [`Math.ceil`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil) on MDN.
## Examples
```rescript
Math.ceil(3.1) == 4.0
Math.ceil(3.0) == 3.0
Math.ceil(-3.1) == -3.0
Math.ceil(2_150_000_000.3) == 2_150_000_001.0
```
*/
@val
external ceil: float => float = "Math.ceil"
/**
`cos(v)` returns the cosine of argument `v`, which must be specified in radians.
See [`Math.cos`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cos) on MDN.
## Examples
```rescript
Math.cos(-0.0) // 1.0
Math.cos(0.0) // 1.0
Math.cos(1.0) // 0.5403023058681398
```
*/
@val
external cos: float => float = "Math.cos"
/**
`cosh(v)` returns the hyperbolic cosine of argument `v`, which must be specified
in radians.
See [`Math.cosh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cosh) on MDN.
## Examples
```rescript
Math.cosh(-1.0) // 1.5430806348152437
Math.cosh(-0.0) // 1.0
Math.cosh(0.0) // 1.0
```
*/
@val
external cosh: float => float = "Math.cosh"
/**
`exp(v)` returns natural exponentional, returns *e* (the base of natural logarithms)
to the power of the given argument `v`.
See [`Math.exp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/exp) on MDN.
## Examples
```rescript
Math.exp(-1.0) // 0.36787944117144233
Math.exp(0.0) // 1.0
```
*/
@val
external exp: float => float = "Math.exp"
/**
`expm1(v)` returns *e* (the base of natural logarithms) to the power of the given
argument `v` minus 1.
See [`Math.expm1`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/expm1) on MDN.
## Examples
```rescript
Math.expm1(-1.0) // -0.6321205588285577
Math.expm1(-0.0) // -0
```
*/
@val
external expm1: float => float = "Math.expm1"
/**
`floor(v)` returns the largest integral value less than or equal to the argument
`v`. The result is a `float` and is not restricted to the `int` data type range.
See [`Math.floor`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor) on MDN.
## Examples
```rescript
Math.floor(-45.95) // -46.0
Math.floor(-45.05) // -46.0
Math.floor(-0.0) // -0.0
```
*/
@val
external floor: float => float = "Math.floor"
/**
`fround(v)` returns the nearest single precision float.
See [`Math.fround`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround) on MDN.
## Examples
```rescript
Math.fround(5.5) == 5.5
Math.fround(5.05) == 5.050000190734863
```
*/
@val
external fround: float => float = "Math.fround"
/**
`hypot(a, b)` returns the square root of the sum of squares of its two arguments
(the Pythagorean formula).
See [`Math.hypot`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot) on MDN.
## Examples
```rescript
Math.hypot(3.0, 4.0) // 5.0
Math.hypot(3.0, 5.0) // 5.8309518948453
```
*/
@val
external hypot: (float, float) => float = "Math.hypot"
/**
`hypotMany(arr)` returns the square root of the sum of squares of the numbers in
the array argument (generalized Pythagorean equation). Using an array allows you
to have more than two items. If `arr` is an empty array then returns `0.0`.
See [`Math.hypot`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot) on MDN.
## Examples
```rescript
Math.hypot([3.0, 4.0, 5.0]) // 7.0710678118654755
Math.hypot([]) // 0.0
```
*/
@variadic
@val
external hypotMany: array<float> => float = "Math.hypot"
/**
`log(v)` returns the natural logarithm of argument `v`, this is the number *x*
such that `e^x` equals the argument. Returns `NaN` for negative arguments and
`Infinity` for `0.0` or `-0.0`.
See [`Math.log`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log) on MDN.
## Examples
```rescript
Math.log(-1.0)->Float.isNaN // true
Math.log(-0.0)->Float.isFinite // false
Math.log(0.0)->Float.isFinite // false
Math.log(1.0) // 0
```
*/
@val
external log: float => float = "Math.log"
/**
`log1p(v)` returns the natural logarithm of one plus the argument `v`.
Returns `NaN` for arguments less than `-1` and `Infinity` if `v` is `-1.0`.
See [`Math.log1p`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log1p) on MDN.
## Examples
```rescript
Math.log1p(-2.0)->Float.isNaN // true
Math.log1p(-1.0)->Float.isFinite // false
Math.log1p(-0.0) // -0
```
*/
@val
external log1p: float => float = "Math.log1p"
/**
`log10(v)` returns the base 10 logarithm of argument `v`. Returns `NaN` for
negative `v`. If `v` is `-0.0` or `0.0` returns `Infinity`.
See [`Math.log10`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log10) on MDN.
## Examples
```rescript
Math.log10(-2.0)->Float.isNaN // true
Math.log10(-0.0)->Float.isFinite // false
Math.log10(0.0)->Float.isFinite // false
Math.log10(1.0) // 0
```
*/
@val
external log10: float => float = "Math.log10"
/**
`log2(v)` returns the base 2 logarithm of argument `v`. Returns `NaN` for
negative `v` and `Infinity` if `v` is `-0.0` or `0.0`.
See [`Math.log2`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log2) on MDN.
## Examples
```rescript
Math.log2(-2.0)->Float.isNaN // true
Math.log2(-0.0)->Float.isFinite // false
Math.log2(0.0)->Float.isFinite // false
Math.log2(1.0) // 0.0
```
*/
@val
external log2: float => float = "Math.log2"
/**
`min(a, b)` returns the minimum of its two float arguments.
See [`Math.min`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min) on MDN.
## Examples
```rescript
Math.min(1.0, 2.0) // 1.0
Math.min(-1.0, -2.0) // -2.0
```
*/
@val
external min: (float, float) => float = "Math.min"
/**
`minMany(arr)` returns the minimum of the float in the given array `arr`.
Returns `Infinity` if `arr` is empty.
See [`Math.min`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min) on MDN.
## Examples
```rescript
Math.minMany([1.0, 2.0]) // 1.0
Math.minMany([-1.0, -2.0]) // -2.0
Math.minMany([]) // 0.0
```
*/
let minMany: array<float> => float
/**
`max(a, b)` returns the maximum of its two float arguments.
See [`Math.max`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max) on MDN.
## Examples
```rescript
Math.max(1.0, 2.0) // 2.0
Math.max(-1.0, -2.0) // -1.0
```
*/
@val
external max: (float, float) => float = "Math.max"
/**
`maxMany(arr)` returns the maximum of the float in the given array `arr`.
Returns `Infinity` if `arr` is empty.
See [`Math.max`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max) on MDN.
## Examples
```rescript
Math.maxMany([1.0, 2.0]) // 2.0
Math.maxMany([-1.0, -2.0]) // -1.0
Math.maxMany([]) // 0.0
```
*/
let maxMany: array<float> => float
/**
`pow(a, ~exp)` raises the given base `a` to the given exponent `exp`.
See [`Math.pow`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow) on MDN.
## Examples
```rescript
Math.pow(2.0, ~exp=4.0) // 16.0
Math.pow(3.0, ~exp=4.0) // 81.0
```
*/
@val
external pow: (float, ~exp: float) => float = "Math.pow"
/**
`random()` returns a random number in the half-closed interval [0,1].
See [`Math.random`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random) on MDN.
## Examples
```rescript
Math.random()
```
*/
@val
external random: unit => float = "Math.random"
/**
`round(v)` returns then value of `v` rounded to nearest integral value
(expressed as a float). If the fractional portion of the argument `v` is greater
than `0.5`, the argument `v` is rounded to the float with the next higher
absolute value.
See [`Math.round`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round) on MDN.
## Examples
```rescript
Math.round(-20.5) // -20.0
Math.round(-0.1) // -0.0
Math.round(0.0) // 0.0
Math.round(-0.0) // -0.0
```
*/
@val
external round: float => float = "Math.round"
/**
`sign(v)` returns the sign of its foat argument: `-1` if negative, `0` if
zero, `1` if positive.
See [`Math.sign`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign) on MDN.
## Examples
```rescript
Math.sign(3.0) // 1.0
Math.sign(-3.0) // 1.0
Math.sign(0.0) // 0.0
```
*/
@val
external sign: float => float = "Math.sign"
/**
`sin(v)` returns the sine of argument `v`, which must be specified in radians.
See [`Math.sin`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sin) on MDN.
## Examples
```rescript
Math.sin(-0.0) // -0.0
Math.sin(0.0) // 0.0
Math.sin(1.0) // 0.8414709848078965
```
*/
@val
external sin: float => float = "Math.sin"
/**
`sinh(v)` returns then hyperbolic sine of argument `v`, which must be specified
in radians.
See [`Math.sinh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sinh) on MDN.
## Examples
```rescript
Math.sinh(-0.0) // -0.0
Math.sinh(0.0) // 0.0
Math.sinh(1.0) // 1.1752011936438014
```
*/
@val
external sinh: float => float = "Math.sinh"
/**
`sqrt(v)` returns the square root of `v`. If `v` is negative returns `NaN`.
See [`Math.sqrt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sqrt) on MDN.
## Examples
```rescript
Math.sqrt(-1.0)->Float.isNaN // true
Math.sqrt(-0.0) // -0.0
Math.sqrt(0.0) // 0.0
Math.sqrt(1.0) // 1.0
Math.sqrt(9.0) // 3.0
```
*/
@val
external sqrt: float => float = "Math.sqrt"
/**
`tan(v)` returns the tangent of argument `v`, which must be specified in
radians. Returns `NaN` if `v` is positive `Infinity` or negative `Infinity`.
See [`Math.tan`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tan) on MDN.
## Examples
```rescript
Math.tan(-0.0) // -0.0
Math.tan(0.0) // 0.0
Math.tan(1.0) // 1.5574077246549023
```
*/
@val
external tan: float => float = "Math.tan"
/**
`tanh(v)` returns the hyperbolic tangent of argument `v`, which must be
specified in radians.
See [`Math.tanh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tanh) on MDN.
## Examples
```rescript
Math.tanh(-0.0) // -0.0
Math.tanh(0.0) // 0.0
Math.tanh(1.0) // 0.7615941559557649
```
*/
@val
external tanh: float => float = "Math.tanh"
/**
`trunc(v)` truncates the argument `v`, i.e., removes fractional digits.
See [`Math.trunc`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc) on MDN.
## Examples
```rescript
Math.trunc(0.123) // 0.0
Math.trunc(1.999) // 1.0
Math.trunc(13.37) // 13.0
Math.trunc(42.84) // 42.0
```
*/
@val
external trunc: float => float = "Math.trunc"