-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathCore__Float.res
36 lines (28 loc) · 1.37 KB
/
Core__Float.res
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
module Constants = {
@val external nan: float = "NaN"
@val external epsilon: float = "Number.EPSILON"
@val external positiveInfinity: float = "Number.POSITIVE_INFINITY"
@val external negativeInfinity: float = "Number.NEGATIVE_INFINITY"
@val external minValue: float = "Number.MIN_VALUE"
@val external maxValue: float = "Number.MAX_VALUE"
}
@val external isNaN: float => bool = "isNaN"
@val external isFinite: float => bool = "isFinite"
@val external parseFloat: 'a => float = "parseFloat"
@send external toExponential: float => string = "toExponential"
@send external toExponentialWithPrecision: (float, ~digits: int) => string = "toExponential"
@send external toFixed: float => string = "toFixed"
@send external toFixedWithPrecision: (float, ~digits: int) => string = "toFixed"
@send external toPrecision: float => string = "toPrecision"
@send external toPrecisionWithPrecision: (float, ~digits: int) => string = "toPrecision"
@send external toString: float => string = "toString"
@send external toStringWithRadix: (float, ~radix: int) => string = "toString"
@send external toLocaleString: float => string = "toLocaleString"
let fromString = i =>
switch parseFloat(i) {
| i if isNaN(i) => None
| i => Some(i)
}
external toInt: float => int = "%intoffloat"
external fromInt: int => float = "%identity"
@unboxed @noalloc external mod: (float, float) => float = "?fmod_float"