lib/bindata/io.rb
# Writes +nbits+ bits from +val+ to the stream in little endian format.
Writes +nbits+ bits from +val+ to the stream in little endian format.
Writes + nbits + bits from + val + to the stream in little endian format .
def write_le_bits(val, nbits)
      while nbits > 0
        bits_req = 8 - @wnbits
        if nbits >= bits_req
          lsb_bits = val & ((1 << bits_req) - 1)
          nbits -= bits_req
          val >>= bits_req
          @wval   |= (lsb_bits << @wnbits)
          @raw_io.write(@wval.chr)
          @wval   = 0
          @wnbits = 0
        else
          @wval   |= (val << @wnbits)
          @wnbits += nbits
          nbits = 0
        end
      end
    end
def write_le_bits ( val , nbits ) while nbits > 0 bits_req = 8 - @wnbits if nbits >= bits_req lsb_bits = val & ( ( 1 << bits_req ) - 1 ) nbits -= bits_req val >>= bits_req @wval |= ( lsb_bits << @wnbits ) @raw_io . write ( @wval . chr ) @wval = 0 @wnbits = 0 else @wval |= ( val << @wnbits ) @wnbits += nbits nbits = 0 end end end
Writes +nbits+ bits from +val+ to the stream in little endian format.
Writes + nbits + bits from + val + to the stream in little endian format .
val
<not_specific>
nbits
<not_specific>