44//Requires: caml_float_of_bytes, caml_ba_get_1
55function bin_prot_get_float_offset ( a , p ) {
66 var t = new Array ( 8 ) ; ;
7- for ( var i = 0 ; i < 8 ; i ++ ) t [ i ] = caml_ba_get_1 ( a , p ++ ) ;
7+ for ( var i = 0 ; i < 8 ; i ++ ) t [ 7 - i ] = caml_ba_get_1 ( a , p ++ ) ;
88 var v = caml_float_of_bytes ( t ) ;
99 return [ 254 , v ] ;
1010}
1111
1212
1313//Provides: bin_prot_blit_buf_float_array_stub
1414//Requires: caml_array_set, caml_ba_get_1
15+ //Requires: caml_int64_of_bytes, caml_int64_float_of_bits
1516function bin_prot_blit_buf_float_array_stub ( v_src_pos , v_buf , v_dst_pos , v_arr , v_len ) {
1617 var c ;
1718 var t = new Array ( 8 ) ; ;
1819 for ( var i = 0 ; i < v_len ; i ++ ) {
19- for ( var j = 0 ; j < 8 ; j ++ ) t [ j ] = caml_ba_get_1 ( v_buf , v_src_pos + j + ( i * 8 ) ) ;
20+ for ( var j = 0 ; j < 8 ; j ++ ) t [ 7 - j ] = caml_ba_get_1 ( v_buf , v_src_pos + j + ( i * 8 ) ) ;
21+ c = caml_int64_float_of_bits ( caml_int64_of_bytes ( t ) ) ;
2022 caml_array_set ( v_arr , v_dst_pos + i , c ) ;
2123 }
2224 return 0
@@ -33,11 +35,14 @@ function bin_prot_blit_buf_string_stub(v_src_pos, v_buf, v_dst_pos, v_str, v_len
3335}
3436//Provides: bin_prot_blit_float_array_buf_stub
3537//Requires: caml_array_get, caml_ba_set_1
38+ //Requires: caml_int64_to_bytes, caml_int64_bits_of_float
3639function bin_prot_blit_float_array_buf_stub ( v_src_pos , v_arr , v_dst_pos , v_buf , v_len ) {
3740 var c ;
3841 for ( var i = 0 ; i < v_len ; i ++ ) {
39- c = caml_array_get ( v_arr , v_src_pos + i ) ;
40- for ( var j = 0 ; j < 8 ; j ++ ) caml_ba_set_1 ( v_buf , v_dst_pos + j + ( i * 8 ) ) ;
42+ var f = caml_array_get ( v_arr , v_src_pos + i ) ;
43+ var a = caml_int64_to_bytes ( caml_int64_bits_of_float ( f ) ) ;
44+ for ( var j = 0 ; j < 8 ; j ++ )
45+ caml_ba_set_1 ( v_buf , v_dst_pos + j + ( i * 8 ) , a [ 7 - j ] ) ;
4146 }
4247 return 0
4348}
0 commit comments