Java Long to long2minLeb(final long x)

Here you can find the source of long2minLeb(final long x)

Description

longmin Leb

License

Apache License

Declaration

public static byte[] long2minLeb(final long x) throws IllegalArgumentException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static byte[] long2minLeb(final long x) throws IllegalArgumentException {
        if (x <= 0xFFFFFFFFFFFFFFL) {
            if (x <= 0xFFFFFFFFFFFFL) {
                if (x <= 0xFFFFFFFFFFL) {
                    if (x <= 0xFFFFFFFFL) {
                        if (x <= 0xFFFFFFL) {
                            if (x <= 0xFFFFL) {
                                if (x <= 0xFFL) {
                                    if (x < 0)
                                        throw new IllegalArgumentException();
                                    return new byte[] { (byte) x };
                                }/*from  w w  w  . j a v a 2  s  .  co m*/
                                return new byte[] { (byte) x, (byte) (x >> 8) };
                            }
                            return new byte[] { (byte) x, (byte) (x >> 8), (byte) (x >> 16) };
                        }
                        return new byte[] { (byte) x, (byte) (x >> 8), (byte) (x >> 16), (byte) (x >> 24) };
                    }
                    return new byte[] { (byte) x, (byte) (x >> 8), (byte) (x >> 16), (byte) (x >> 24),
                            (byte) (x >> 32) };
                }
                return new byte[] { (byte) x, (byte) (x >> 8), (byte) (x >> 16), (byte) (x >> 24), (byte) (x >> 32),
                        (byte) (x >> 40) };
            }
            return new byte[] { (byte) x, (byte) (x >> 8), (byte) (x >> 16), (byte) (x >> 24), (byte) (x >> 32),
                    (byte) (x >> 40), (byte) (x >> 48) };
        }

        return new byte[] { (byte) x, (byte) (x >> 8), (byte) (x >> 16), (byte) (x >> 24), (byte) (x >> 32),
                (byte) (x >> 40), (byte) (x >> 48), (byte) (x >> 56) };
    }
}

Related

  1. long2FourChars(long i)
  2. Long2H(final long l)
  3. long2leb(final long x, final byte[] buf, final int offset)
  4. long2longArr(long val, long[] res)
  5. long2MacAddress(long l)
  6. longTo36Str(String str)
  7. longTo4ByteArray(byte[] bytes, int offset, long value)
  8. longTo4LengthBytes(long num)
  9. LongToAscii(long number, byte[] buf, int offset, int length)