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