OSDN Git Service

disable half-precision
authormzp <mzpppp@gmail.com>
Sat, 3 Oct 2009 21:30:33 +0000 (06:30 +0900)
committermzp <mzpppp@gmail.com>
Sat, 3 Oct 2009 21:30:33 +0000 (06:30 +0900)
swflib/swfBaseOut.ml
swflib/swfBaseOut.mli
swflib/swfBaseOutTest.ml

index 127e1ac..b21e755 100644 (file)
@@ -12,7 +12,6 @@ type t =
   | Ui64 of int64
   | Fixed of float
   | Fixed8 of float
-  | Float16 of float
   | Float32 of float
   | Float64 of float
 
@@ -60,31 +59,6 @@ and encode = function
        (x -. int) *. float 0x1_00 in
        to_int_list [Ui8 (int_of_float decimal);
                     Ui8 (int_of_float int)]
-  | Float16 x ->
-      (*
-       [single precision]
-       Sign bit: 1 bit
-       Exponent width: 8 bits
-       Significand precision: 23 bits
-
-       [half presicion]
-       Sign bit: 1 bit
-       Exponent width: 5 bit
-       Significand precision: 10 bits
-      *)
-      let single =
-       Int32.bits_of_float x in
-      let sign =
-       Int32.to_int @@ Int32.shift_right_logical single 31 in
-      let exp =
-       Int32.to_int @@ Int32.logand 0xFFl  @@ Int32.shift_right_logical single 23 in
-      let prec =
-       Int32.to_int @@ Int32.logand 0x3FFl @@ single in
-      let half =
-       (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)
   | Float64 x ->
index 58a6475..da208af 100644 (file)
@@ -10,7 +10,6 @@ type t =
   | Ui64 of int64
   | Fixed of float
   | Fixed8 of float
-  | Float16 of float
   | Float32 of float
   | Float64 of float
 
index 9875485..ab80601 100644 (file)
@@ -60,11 +60,11 @@ let _ = begin "swfBaseOut.ml" >::: [
     ok_b [Ui8 0x80; Ui8 7] [Fixed8 7.5];
     ok_b [Ui8 0; Ui8 0xFF] [Fixed8 255.0];
   end;
-  "Float16" >:: begin fun() ->
+(*  "Float16" >:: begin fun() ->
     ok_i [0; 0x3c] @@ Float16 1.;
     ok_i [0; 0xc0] @@ Float16 (-2.0);
-    ok_i [0x55; 0x35] @@ Float16 (1. /. 3.);
-  end;
+    ok_i [0xff; 0x7b] @@ Float16 65504.;
+  end;*)
   "Float32" >:: begin fun() ->
     ok_i [0; 0; 0x20; 0x40] @@ Float32 2.5;
   end;