OSDN Git Service

updateTest case
authormzp <mzpppp@gmail.com>
Sat, 3 Oct 2009 12:22:13 +0000 (21:22 +0900)
committermzp <mzpppp@gmail.com>
Sat, 3 Oct 2009 12:22:13 +0000 (21:22 +0900)
swflib/swfBaseOut.ml
swflib/swfBaseOutTest.ml

index 96773d4..127e1ac 100644 (file)
@@ -77,11 +77,13 @@ and encode = function
       let sign =
        Int32.to_int @@ Int32.shift_right_logical single 31 in
       let exp =
-       Int32.to_int @@ Int32.logand 0b1_1111l @@ Int32.shift_right_logical single 23 in
+       Int32.to_int @@ Int32.logand 0xFFl  @@ Int32.shift_right_logical single 23 in
       let prec =
-       Int32.to_int @@ Int32.logand 0b11_1111_1111l @@ single in
+       Int32.to_int @@ Int32.logand 0x3FFl @@ single in
       let half =
-       (sign lsl 15) lor ((exp + 127 - 15) lsl 10) lor prec in
+       (sign lsl 15) lor (((exp + 127 - 15) land 0x1F) lsl 10) lor (prec lsr 13) in
+      let _ =
+       Std.print (sign,exp,prec) in
        encode @@ Ui16 half
   | Float32 x ->
       encode @@ Ui32 (Int32.bits_of_float x)
index 042403e..9875485 100644 (file)
@@ -63,6 +63,7 @@ let _ = begin "swfBaseOut.ml" >::: [
   "Float16" >:: begin fun() ->
     ok_i [0; 0x3c] @@ Float16 1.;
     ok_i [0; 0xc0] @@ Float16 (-2.0);
+    ok_i [0x55; 0x35] @@ Float16 (1. /. 3.);
   end;
   "Float32" >:: begin fun() ->
     ok_i [0; 0; 0x20; 0x40] @@ Float32 2.5;