Method: Tros::IO::BinaryEncoder#write_long

Defined in:
lib/tros/io.rb

#write_long(n) ⇒ Object Also known as: write_int

int and long values are written using variable-length, zig-zag coding.



171
172
173
174
175
176
177
178
179
# File 'lib/tros/io.rb', line 171

def write_long(n)
  foo = n
  n = (n << 1) ^ (n >> 63)
  while (n & ~0x7F) != 0
    @writer.write(((n & 0x7f) | 0x80).chr)
    n >>= 7
  end
  @writer.write(n.chr)
end