def convert_endianness!(from_endianness, to_endianness)
    if from_endianness!=to_endianness
      if ([:little_endian,:big_endian]+[from_endianness, to_endianness]).uniq.size==2
        # no middle_endian order
        reverse!
      else
        # from or to is middle_endian
        if [:middle_endian, :little_big_endian].include?(to_endianness)
          # from little_big_endian
          convert_endianness!(from_endianness, :big_endian).reverse_byte_pairs!
        else
          # from little_big_endian
          reverse_byte_pairs!.convert_endianness!(:big_endian, to_endianness)
        end
      end
    end
    self
  end
def convert_endianness!(from_endianness, to_endianness)
    if from_endianness!=to_endianness
      if ([:little_endian,:big_endian]+[from_endianness, to_endianness]).uniq.size==2
        # no middle_endian order
        reverse!
      else
        # from or to is middle_endian
        if [:middle_endian, :little_big_endian].include?(to_endianness)
          # from little_big_endian
          convert_endianness!(from_endianness, :big_endian).reverse_byte_pairs!
        else
          # from little_big_endian
          reverse_byte_pairs!.convert_endianness!(:big_endian, to_endianness)
        end
      end
    end
    self
  end
Supported endianness modes for byte strings are:
 [<tt>:little_endian</tt>] (Intel order): least significant bytes come first.
 [<tt>:big_endian</tt>] (Network order): most significant bytes come first.
 [<tt>:little_big_endian</tt> or <tt>:middle_endian</tt>] (PDP-11 order): each pair of bytes
                                                          (16-bit word) has the bytes in little endian order, but the words
                                                          are stored in big endian order (we assume the number of bytes is even).
 Note that the <tt>:big_little_endian</tt> order which would logically complete the set is
 not currently supported as it has no known uses.