瀏覽代碼

Fix floatS8to32 with negative values.

clementlandrin 1 年之前
父節點
當前提交
8ecaabe2b4
共有 1 個文件被更改,包括 5 次插入2 次删除
  1. 5 2
      hxd/BufferFormat.hx

+ 5 - 2
hxd/BufferFormat.hx

@@ -440,8 +440,11 @@ class BufferFormat {
 		return i >= 0 ? i : (0x7F + i) | 0x80;
 	}
 
-	public static function floatS8to32( v : Int ) {
-		return (v & 0x80 != 0 ? -1 : 1) * ((v&0x7F)/127);
+	public static function floatS8to32( v : Int ) : Float {
+		if ( v & 0x80 != 0 )
+			return -1*(0x7F-(v&0x7F))/128;
+		else
+			return (v&0x7F)/128;
 	}
 
 	public static function float32toU8( v : Float ) : Int {