Android Big Endian Convert switchEndian(long l)

Here you can find the source of switchEndian(long l)

Description

switch Endian

Declaration

public static final long switchEndian(long l) 

Method Source Code

//package com.java2s;

public class Main {
    public static final long switchEndian(long l) {
        return (l >>> 56) | ((l >>> 40) & 0x0000FF00)
                | ((l >>> 24) & 0x00FF0000) | ((l >>> 8) & 0xFF000000L)
                | ((l & 0xFF000000L) << 8) | ((l & 0x00FF0000) << 24)
                | ((l & 0x0000FF00) << 40) | (l << 56);
    }/*from   ww w  .  j  ava 2s.  c  om*/

    public static final int switchEndian(int i) {
        return ((i & 0xff000000) >>> 24) | ((i & 0x00ff0000) >>> 8)
                | ((i & 0x0000ff00) << 8) | ((i & 0x000000ff) << 24);
    }

    public static final short switchEndian(short i) {
        return (short) (((i & 0xff00) >>> 8) | ((i & 0x00ff) << 8));
    }
}

Related

  1. toggleShortEndian(byte[] b)
  2. toggleShortEndian(byte[] b, int off, int len)
  3. getInt(byte[] data, int i, boolean bigEndian)
  4. getShort(byte[] data, int i, boolean bigEndian)
  5. switchEndian(int i)
  6. switchEndian(short i)
  7. setBigIndianInBytesArray(byte[] toPutIn, int startidx, long theNumber, int len)
  8. setLittleIndianInBytesArray(byte[] toPutIn, int startidx, long theNumber, int len)