Nicolas Cannasse 2 rokov pred
rodič
commit
6528ebc07a
1 zmenil súbory, kde vykonal 4 pridanie a 4 odobranie
  1. 4 4
      hxd/BufferFormat.hx

+ 4 - 4
hxd/BufferFormat.hx

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