2
2
'use strict' ;
3
3
4
4
5
+ function caml_int64_float_of_bits ( x ) {
6
+ var to_int32 = function ( x ) {
7
+ return x ;
8
+ } ;
9
+ var int32 = new Int32Array ( /* array */ [
10
+ to_int32 ( x [ /* lo */ 0 ] ) ,
11
+ to_int32 ( x [ /* hi */ 1 ] )
12
+ ] ) ;
13
+ return new Float64Array ( int32 . buffer ) [ 0 ] ;
14
+ }
5
15
6
- function $$ caml_int64_bits_of_float ( x ) {
7
- // TODO:
8
- // can be allocated globally to avoid allocation each time
9
- // Need check existense of the API we used here
10
- var u = new Float64Array ( [ x ] ) ;
16
+ function caml_int64_bits_of_float ( x ) {
17
+ var to_nat = function ( x ) {
18
+ return x ;
19
+ } ;
20
+ var u = new Float64Array ( /* float array */ [ x ] ) ;
11
21
var int32 = new Int32Array ( u . buffer ) ;
12
- // actually we can return it directly without a conversion
13
- return [ int32 [ 0 ] , int32 [ 1 ] ] ;
22
+ return /* record */ [
23
+ to_nat ( int32 [ 0 ] ) ,
24
+ to_nat ( int32 [ 1 ] )
25
+ ] ;
14
26
}
15
27
16
- function $$caml_int64_float_of_bits ( x ) {
17
- var int32 = new Int32Array ( x ) ;
18
- var float64 = new Float64Array ( int32 . buffer ) ;
19
- return float64 [ 0 ] ;
28
+ function caml_int32_float_of_bits ( x ) {
29
+ var int32 = new Int32Array ( /* array */ [ x ] ) ;
30
+ var float32 = new Float32Array ( int32 . buffer ) ;
31
+ return float32 [ 0 ] ;
20
32
}
21
33
22
- ;
34
+ function caml_int32_bits_of_float ( x ) {
35
+ var float32 = new Float32Array ( /* float array */ [ x ] ) ;
36
+ return new Int32Array ( float32 . buffer ) [ 0 ] ;
37
+ }
23
38
24
39
function caml_classify_float ( x ) {
25
40
if ( isFinite ( x ) ) {
@@ -166,14 +181,6 @@ function $$caml_log10_float (x) { return Math.LOG10E * Math.log(x); }
166
181
167
182
;
168
183
169
- function caml_int64_bits_of_float ( prim ) {
170
- return $$caml_int64_bits_of_float ( prim ) ;
171
- }
172
-
173
- function caml_int64_float_of_bits ( prim ) {
174
- return $$caml_int64_float_of_bits ( prim ) ;
175
- }
176
-
177
184
function caml_ldexp_float ( prim , prim$1 ) {
178
185
return $$caml_ldexp_float ( prim , prim$1 ) ;
179
186
}
@@ -186,8 +193,10 @@ function caml_hypot_float(prim, prim$1) {
186
193
return $$caml_hypot_float ( prim , prim$1 ) ;
187
194
}
188
195
189
- exports . caml_int64_bits_of_float = caml_int64_bits_of_float ;
190
196
exports . caml_int64_float_of_bits = caml_int64_float_of_bits ;
197
+ exports . caml_int32_float_of_bits = caml_int32_float_of_bits ;
198
+ exports . caml_int64_bits_of_float = caml_int64_bits_of_float ;
199
+ exports . caml_int32_bits_of_float = caml_int32_bits_of_float ;
191
200
exports . caml_classify_float = caml_classify_float ;
192
201
exports . caml_modf_float = caml_modf_float ;
193
202
exports . caml_ldexp_float = caml_ldexp_float ;
0 commit comments