Java Long Number Create fromLongLE(byte src[], int offset, int numBytes)

Here you can find the source of fromLongLE(byte src[], int offset, int numBytes)

Description

Little endian, i.e.

License

Open Source License

Parameter

Parameter Description
numBytes 1-8

Exception

Parameter Description
AIOOBE an exception
IllegalArgumentException if negative (only possible if numBytes = 8)

Return

non-negative

Declaration

public static long fromLongLE(byte src[], int offset, int numBytes) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from   www  .  j a v  a 2 s  . c  om*/
     * Little endian, i.e. backwards. Not for use in I2P protocols.
     *
     * @param numBytes 1-8
     * @return non-negative
     * @throws AIOOBE
     * @throws IllegalArgumentException if negative (only possible if numBytes = 8)
     * @since 0.8.12
     */
    public static long fromLongLE(byte src[], int offset, int numBytes) {
        if (numBytes <= 0 || numBytes > 8)
            throw new IllegalArgumentException("Invalid number of bytes");
        long rv = 0;
        for (int i = offset + numBytes - 1; i >= offset; i--) {
            rv <<= 8;
            rv |= src[i] & 0xFF;
        }
        if (rv < 0)
            throw new IllegalArgumentException(
                    "wtf, fromLong got a negative? " + rv + ": offset=" + offset + " numBytes=" + numBytes);
        return rv;
    }
}

Related

  1. convertLongitudeFromMercator( double mercatorLongitude)
  2. convertLongPriceToString(long price)
  3. convertLongtoMultiByte(long val)
  4. fromLong(byte[] buffer, int pos, long l)
  5. fromLong(long value, byte[] arr, int offset)
  6. toLong(boolean b)
  7. toLong(boolean... a)
  8. toLong(byte b)
  9. toLong(byte byte7, byte byte6, byte byte5, byte byte4, byte byte3, byte byte2, byte byte1, byte byte0)