Показать сообщение отдельно
Старый 09.12.2009, 18:53
bicubic_bublic вне форума Посмотреть профиль Найти все сообщения от bicubic_bublic
  № 2  
Ответить с цитированием
bicubic_bublic
Banned

Регистрация: Sep 2009
Сообщений: 231
оттуда же:
Цитата:
The variable-length encoding for u30, u32, and s32 uses one to five bytes, depending on the magnitude of the
value encoded. Each byte contributes its low seven bits to the value. If the high (eighth) bit of a byte is set,
then the next byte of the abcFile is also part of the value. In the case of s32, sign extension is applied: the
seventh bit of the last byte of the encoding is propagated to fill out the 32 bits of the decoded value.
Добавлено через 6 минут
Код AS3:
function writeU32(ba:ByteArray, value:uint) {
   if (value == 0) {
      ba.writeByte(0);
   }
   var byte:uint;
   while (value != 0) {
      byte = value & 0x0000007f; // отрезаем 7 бит от числа
      value = value >> 7; //смещаем на 7 бит
      if (value != 0) { //если что-то еще осталось добавляем 8-й бит флаг
         byte = byte | 0x00000080;
      }
      ba.writeByte(byte); //пишем текущий байт..
   }
}


Последний раз редактировалось bicubic_bublic; 09.12.2009 в 19:02.