Converts identifier to a byte array
@param bigEndian true if bytes are MSB first
@return a new byte array with a copy of the value
160953
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
    public byte[] toByteArrayOfSpecifiedEndianness(boolean bigEndian) {
        byte[] copy = Arrays.copyOf(mValue, mValue.length);

        if (!bigEndian) {
            reverseArray(copy);
        }

        return copy;
    }
1340928
public static byte[] toUnsignedByteArray(int length, BigInteger value) {
		byte[] bytes = value.toByteArray();
		if (bytes.length == length) {
			return bytes;
		}

		int start = bytes[0] == 0 ? 1 : 0;
		int count = bytes.length - start;

		if (count > length) {
			throw new IllegalArgumentException("standard length exceeded for value");
		}

		byte[] tmp = new byte[length];
		System.arraycopy(bytes, start, tmp, tmp.length - count, count);
		return tmp;
	}
512398
public MessagePacker packBigInteger(BigInteger bi)
            throws IOException
    {
        if (bi.bitLength() <= 63) {
            packLong(bi.longValue());
        }
        else if (bi.bitLength() == 64 && bi.signum() == 1) {
            writeByteAndLong(UINT64, bi.longValue());
        }
        else {
            throw new IllegalArgumentException("MessagePack cannot serialize BigInteger larger than 2^64-1");
        }
        return this;
    }
590482
public static long readLongLittleEndian(InputStream io) throws IOException {
		long value = io.read();
		if (value < 0) throw new EOFException();
		int i = io.read();
		if (i < 0) throw new EOFException();
		value |= i << 8;
		i = io.read();
		if (i < 0) throw new EOFException();
		value |= i << 16;
		i = io.read();
		if (i < 0) throw new EOFException();
		value |= ((long)i) << 24;
		i = io.read();
		if (i < 0) throw new EOFException();
		value |= ((long)i) << 32;
		i = io.read();
		if (i < 0) throw new EOFException();
		value |= ((long)i) << 40;
		i = io.read();
		if (i < 0) throw new EOFException();
		value |= ((long)i) << 48;
		i = io.read();
		if (i < 0) throw new EOFException();
		value |= ((long)i) << 56;
		return value;
	}
670787
BigInteger toBigInteger(int sign) {
        if (intLen == 0 || sign == 0)
            return BigInteger.ZERO;
        return new BigInteger(getMagnitudeArray(), sign);
    }
511116
public BigInteger asBigInteger() throws IOException {
        if (_value instanceof BigInteger) {
            return (BigInteger) _value;
        }
        if (_value instanceof BigDecimal) {
            BigDecimal dec = (BigDecimal) _value;
            return dec.toBigInteger();
        }
        return BigInteger.valueOf(_value.longValue());
    }
932860
public JBBPDslBuilder ByteOrder(final JBBPByteOrder order) {
    this.byteOrder = order == null ? JBBPByteOrder.BIG_ENDIAN : order;
    return this;
  }
966467
public static int toShort(byte[] b, int off, boolean littleEndian) {
		if (littleEndian) {
			return ((b[off] & 0xFF) | ((b[off + 1] & 0xFF) << 8));
		}
		return (((b[off] & 0xFF) << 8) | (b[off + 1] & 0xFF));
	}
797667
public static Guid fromByteArrays(byte[]... byteArrays) throws IOException {
    if (byteArrays == null || byteArrays.length == 0) {
      throw new IOException("Attempting to compute guid for an empty array.");
    }

    if (byteArrays.length == 1) {
      return new Guid(byteArrays[0]);
    }
    byte[] tmp = new byte[0];
    for (byte[] arr : byteArrays) {
      tmp = ArrayUtils.addAll(tmp, arr);
    }
    return new Guid(tmp);
  }
274851
@Override
    public int encode ( byte[] dst, int dstIndex ) {
        int start = dstIndex;
        SMBUtil.writeInt8(this.offset, dst, dstIndex);
        dstIndex += 8;
        SMBUtil.writeInt8(this.length, dst, dstIndex);
        dstIndex += 8;

        SMBUtil.writeInt4(this.flags, dst, dstIndex);
        dstIndex += 4;
        dstIndex += 4; // Reserved
        return dstIndex - start;
    }
918612
public static void writeIntegerLittleEndian(ByteBuffer io, int value) {
		io.put((byte)(value & 0xFF));
		io.put((byte)((value >> 8) & 0xFF));
		io.put((byte)((value >> 16) & 0xFF));
		io.put((byte)((value >> 24) & 0xFF));
	}
1173172
public GenericNack genericNack(byte[] b) {
        GenericNack req = new GenericNack();
        assignHeader(req, b);
        return req;
    }
902025
static BigInteger castToBigInteger(final byte[] chunk, final int maxLength, final boolean requireMinimal) throws ScriptException {
        if (chunk.length > maxLength)
            throw new ScriptException(ScriptError.SCRIPT_ERR_UNKNOWN_ERROR, "Script attempted to use an integer larger than " + maxLength + " bytes");

        if (requireMinimal && chunk.length > 0) {
            // Check that the number is encoded with the minimum possible
            // number of bytes.
            //
            // If the most-significant-byte - excluding the sign bit - is zero
            // then we're not minimal. Note how this test also rejects the
            // negative-zero encoding, 0x80.
            if ((chunk[chunk.length - 1] & 0x7f) == 0) {
                // One exception: if there's more than one byte and the most
                // significant bit of the second-most-significant-byte is set
                // it would conflict with the sign bit. An example of this case
                // is +-255, which encode to 0xff00 and 0xff80 respectively.
                // (big-endian).
                if (chunk.length <= 1 || (chunk[chunk.length - 2] & 0x80) == 0) {
                    throw  new ScriptException(ScriptError.SCRIPT_ERR_UNKNOWN_ERROR, "non-minimally encoded script number");
                }
            }
        }

        return Utils.decodeMPI(Utils.reverseBytes(chunk), false);
    }
522646
def unpack_int64_bigendian(bytes)
      bytes.each_byte.to_a.reverse.each_with_index.
        reduce(0) { |val, (byte, index)| val | (byte << (index * 8)) }
    end
891608
public static void writeIntegerLittleEndian(IO.WritableByteStream io, int value) throws IOException {
		io.write((byte)(value & 0xFF));
		io.write((byte)((value >> 8) & 0xFF));
		io.write((byte)((value >> 16) & 0xFF));
		io.write((byte)((value >> 24) & 0xFF));
	}
1220243
@Override
    public IWordDeserializer getDeserializer(HLLType type, int wordLength, byte[] bytes) {
        return new BigEndianAscendingWordDeserializer(wordLength, paddingBytes(type), bytes);
    }
1358333
public static byte[] integerToBytes(BigInteger s, int length) {
      byte[] bytes = s.toByteArray();
      if (length < bytes.length) {
         // The length is smaller than the byte representation. Truncate by
         // copying over the least significant bytes
         byte[] tmp = new byte[length];
         System.arraycopy(bytes, bytes.length - tmp.length, tmp, 0, tmp.length);
         return tmp;
      } else if (length > bytes.length) {
         // The length is larger than the byte representation. Copy over all
         // bytes and leave it prefixed by zeros.
         byte[] tmp = new byte[length];
         System.arraycopy(bytes, 0, tmp, tmp.length - bytes.length, bytes.length);
         return tmp;
      }
      return bytes;
   }