Fix issues with writing negative numbers as non-zigzag varints, close #493

This commit is contained in:
Dylan K. Taylor 2017-03-31 18:59:40 +01:00
parent 87a52a4f35
commit 16972bf9a5

View File

@ -395,6 +395,7 @@ class Binary{
*/
public static function writeUnsignedVarInt($value){
$buf = "";
$value &= 0xffffffff;
for($i = 0; $i < 5; ++$i){
if(($value >> 7) !== 0){
$buf .= chr($value | 0x80); //Let chr() take the last byte of this, it's faster than adding another & 0x7f.