Nicolas Cannasse 2 лет назад
Родитель
Сommit
6528ebc07a
1 измененных файлов с 4 добавлено и 4 удалено
  1. 4 4
      hxd/BufferFormat.hx

+ 4 - 4
hxd/BufferFormat.hx

@@ -307,12 +307,12 @@ class BufferFormat {
 	}
 
 	public static function float32toS8( v : Float ) : Int {
-		if( v >= 1 )
+		var i = Math.floor(v * 128);
+		if( i >= 127 )
 			return 0x7F;
-		if( v <= -1 )
+		if( i <= -127 )
 			return 0x80;
-		var i = Math.floor(v * 128);
-		return v >= 0 ? i : (0x7F - i) | 0x80;
+		return i >= 0 ? i : (0x7F + i) | 0x80;
 	}
 
 	public static function floatS8to32( v : Int ) {