@@ -114,8 +114,27 @@ module Constants: {
114114 external maxValue : float = "Number.MAX_VALUE"
115115}
116116
117+ /**
118+ Checks if two floating point numbers are equal.
119+
120+ ## Examples
121+ ```rescript
122+ Float.equal(1.0, 1.0) == true
123+ Float.equal(1.0, 2.0) == false
124+ ```
125+ */
117126external equal : (float , float ) => bool = "%equal"
118127
128+ /**
129+ Compares two floating point numbers, returns an `Ordering.t` value.
130+
131+ ## Examples
132+ ```rescript
133+ Float.compare(1.0, 1.0) == Ordering.equal
134+ Float.compare(1.0, 2.0) == Ordering.less
135+ Float.compare(2.0, 1.0) == Ordering.greater
136+ ```
137+ */
119138external compare : (float , float ) => Stdlib_Ordering .t = "%compare"
120139
121140/**
@@ -139,9 +158,9 @@ See [`isFinite`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referen
139158## Examples
140159
141160```rescript
142- Float.isFinite(1.0) // true
143- Float.isFinite(Float.Constants.nan) // false
144- Float.isFinite(Float.Constants.positiveInfinity) // false
161+ Float.isFinite(1.0) == true
162+ Float.isFinite(Float.Constants.nan) == false
163+ Float.isFinite(Float.Constants.positiveInfinity) == false
145164```
146165*/
147166@val
@@ -156,11 +175,11 @@ See [`parseFloat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refer
156175## Examples
157176
158177```rescript
159- Float.parseFloat("1.0") // 1.0
160- Float.parseFloat(" 3.14 ") // 3.14
161- Float.parseFloat("3.0") // 3.0
162- Float.parseFloat("3.14some non-digit characters") // 3.14
163- Float.parseFloat("error")->Float.isNaN // true
178+ Float.parseFloat("1.0") == 1.0
179+ Float.parseFloat(" 3.14 ") == 3.14
180+ Float.parseFloat("3.0") == 3.0
181+ Float.parseFloat("3.14some non-digit characters") == 3.14
182+ Float.parseFloat("error")->Float.isNaN == true
164183```
165184*/
166185@val
@@ -177,15 +196,15 @@ See [`parseInt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referen
177196## Examples
178197
179198```rescript
180- Float.parseInt("1.0") // 1.0
181- Float.parseInt(" 3.14 ") // 3.0
182- Float.parseInt(3) // 3.0
183- Float.parseInt("3.14some non-digit characters") // 3.0
184- Float.parseInt("error")->Float.isNaN // true
185- Float.parseInt("10.0", ~radix=2) // 2.0
186- Float.parseInt("15 * 3", ~radix=10) // 15.0
187- Float.parseInt("12", ~radix=13) // 15.0
188- Float.parseInt("17", ~radix=40)->Float.isNaN // true
199+ Float.parseInt("1.0") == 1.0
200+ Float.parseInt(" 3.14 ") == 3.0
201+ Float.parseInt(3) == 3.0
202+ Float.parseInt("3.14some non-digit characters") == 3.0
203+ Float.parseInt("error")->Float.isNaN == true
204+ Float.parseInt("10.0", ~radix=2) == 2.0
205+ Float.parseInt("15 * 3", ~radix=10) == 15.0
206+ Float.parseInt("12", ~radix=13) == 15.0
207+ Float.parseInt("17", ~radix=40)->Float.isNaN == true
189208```
190209*/
191210@val
@@ -202,10 +221,10 @@ See [`parseInt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referen
202221## Examples
203222
204223```rescript
205- Float.parseIntWithRadix("10.0", ~radix=2) // 2.0
206- Float.parseIntWithRadix("15 * 3", ~radix=10) // 15.0
207- Float.parseIntWithRadix("12", ~radix=13) // 15.0
208- Float.parseIntWithRadix("17", ~radix=40)->Float.isNaN // true
224+ Float.parseIntWithRadix("10.0", ~radix=2) == 2.0
225+ Float.parseIntWithRadix("15 * 3", ~radix=10) == 15.0
226+ Float.parseIntWithRadix("12", ~radix=13) == 15.0
227+ Float.parseIntWithRadix("17", ~radix=40)->Float.isNaN == true
209228```
210229*/
211230@deprecated ("Use `parseInt` instead" ) @val
@@ -220,10 +239,10 @@ See [`Number.toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaSc
220239## Examples
221240
222241```rescript
223- Float.toExponential(1000.0) // "1e+3"
224- Float.toExponential(-1000.0) // "-1e+3"
225- Float.toExponential(77.0, ~digits=2) // "7.70e+1"
226- Float.toExponential(5678.0, ~digits=2) // "5.68e+3"
242+ Float.toExponential(1000.0) == "1e+3"
243+ Float.toExponential(-1000.0) == "-1e+3"
244+ Float.toExponential(77.0, ~digits=2) == "7.70e+1"
245+ Float.toExponential(5678.0, ~digits=2) == "5.68e+3"
227246```
228247
229248## Exceptions
@@ -242,8 +261,8 @@ See [`Number.toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaSc
242261## Examples
243262
244263```rescript
245- Float.toExponentialWithPrecision(77.0, ~digits=2) // "7.70e+1"
246- Float.toExponentialWithPrecision(5678.0, ~digits=2) // "5.68e+3"
264+ Float.toExponentialWithPrecision(77.0, ~digits=2) == "7.70e+1"
265+ Float.toExponentialWithPrecision(5678.0, ~digits=2) == "5.68e+3"
247266```
248267
249268## Exceptions
@@ -262,10 +281,10 @@ See [`Number.toFixed`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/R
262281## Examples
263282
264283```rescript
265- Float.toFixed(123456.0) // "123456.00 "
266- Float.toFixed(10.0) // "10.00 "
267- Float.toFixed(300.0, ~digits=4) // "300.0000"
268- Float.toFixed(300.0, ~digits=1) // "300.0"
284+ Float.toFixed(123456.0) == "123456"
285+ Float.toFixed(10.0) == "10"
286+ Float.toFixed(300.0, ~digits=4) == "300.0000"
287+ Float.toFixed(300.0, ~digits=1) == "300.0"
269288```
270289
271290## Exceptions
@@ -284,8 +303,8 @@ See [`Number.toFixed`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/R
284303## Examples
285304
286305```rescript
287- Float.toFixedWithPrecision(300.0, ~digits=4) // "300.0000"
288- Float.toFixedWithPrecision(300.0, ~digits=1) // "300.0"
306+ Float.toFixedWithPrecision(300.0, ~digits=4) == "300.0000"
307+ Float.toFixedWithPrecision(300.0, ~digits=1) == "300.0"
289308```
290309
291310## Exceptions
@@ -303,10 +322,10 @@ See [`Number.toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScri
303322## Examples
304323
305324```rescript
306- Float.toPrecision(100.0) // "100"
307- Float.toPrecision(1.0) // "1"
308- Float.toPrecision(100.0, ~digits=2) // "1.0e+2"
309- Float.toPrecision(1.0, ~digits=1) // "1"
325+ Float.toPrecision(100.0) == "100"
326+ Float.toPrecision(1.0) == "1"
327+ Float.toPrecision(100.0, ~digits=2) == "1.0e+2"
328+ Float.toPrecision(1.0, ~digits=1) == "1"
310329```
311330
312331## Exceptions
@@ -326,8 +345,8 @@ See [`Number.toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScri
326345## Examples
327346
328347```rescript
329- Float.toPrecisionWithPrecision(100.0, ~digits=2) // "1.0e+2"
330- Float.toPrecisionWithPrecision(1.0, ~digits=1) // "1"
348+ Float.toPrecisionWithPrecision(100.0, ~digits=2) == "1.0e+2"
349+ Float.toPrecisionWithPrecision(1.0, ~digits=1) == "1"
331350```
332351
333352## Exceptions
@@ -347,8 +366,8 @@ See [`Number.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/
347366## Examples
348367
349368```rescript
350- Float.toString(1000.0) // "1000"
351- Float.toString(-1000.0) // "-1000"
369+ Float.toString(1000.0) == "1000"
370+ Float.toString(-1000.0) == "-1000"
352371```
353372*/
354373@send
@@ -362,9 +381,9 @@ See [`Number.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/
362381## Examples
363382
364383```rescript
365- Float.toStringWithRadix(6.0, ~radix=2) // "110"
366- Float.toStringWithRadix(3735928559.0, ~radix=16) // "deadbeef"
367- Float.toStringWithRadix(123456.0, ~radix=36) // "2n9c"
384+ Float.toStringWithRadix(6.0, ~radix=2) == "110"
385+ Float.toStringWithRadix(3735928559.0, ~radix=16) == "deadbeef"
386+ Float.toStringWithRadix(123456.0, ~radix=36) == "2n9c"
368387```
369388
370389## Exceptions
0 commit comments