# Class MultiBitNums

Class of multiple multi-bit data packed in a C string. The number of bits is fixed to an arbitrary value. For example, it can accommodate 11-bit integers.

### Function overview

Integer encoding/decoding (so far only decoding has been implemented):

- Each segment of data is assumed to be multi-bit (fixed-length) unsigned integer in network byte order (big endian).
- Note: integers of the system does not have to be big-endian (Only the binary data is interpreted as unsigned big-endian).

### Class Methods

`MultiBitNums.new( str, nbit [, nint] )`

  Creates a new object from a binary data (string) containing multi-bit segments.

  ARGUMENTS

  - str (String): binary data containing multi-bit data
  - nbit (Integer): length in bits of each segments contained in str
  - nint (Integer, can be omitted): number of nbit-bit data in str. If omitted, derived automatically from the length of str.

  RETURN VALUE

  - a MultiBitNums object

  ERRORS

  - exception is raised if nint is too large for the length of str.

### Instance Methods

`to_int32str`

  Converts into a string containing binary data of 32-bit integers of the system. Useful with NArray.

  ARGUMENTS

      (none)

  RETURN VALUE

  - a String (Its binary expression depends on the integer expression of the system).

  ERRORS

  - exception is raised if nbit (see MultiBitNums.new) is greater than 32.

  EXAMPLE

      mb = MultiBitNums.new(str, nbits)
      require "narray"           # download it from RAA at www.ruby-lang.org
      ary = NArray.to_na( mb, "int" )  # the data is read into a NArray ary