Android Int Bit Shift swap(int x)

Here you can find the source of swap(int x)

Description

swap

Declaration

static int swap(int x) 

Method Source Code

//package com.java2s;

public class Main {
    static short swap(short x) {
        return (short) ((x << 8) | ((x >> 8) & 0xff));
    }//from w w  w.ja  v  a 2s .com

    static char swap(char x) {
        return (char) ((x << 8) | ((x >> 8) & 0xff));
    }

    static int swap(int x) {
        return (int) ((swap((short) x) << 16) | (swap((short) (x >> 16)) & 0xffff));
    }

    static long swap(long x) {
        return (long) (((long) swap((int) (x)) << 32) | ((long) swap((int) (x >> 32)) & 0xffffffffL));
    }
}

Related

  1. nextPowerOf2(int n)
  2. toByta(int data)
  3. flip16(int num)
  4. swapBytes(int value)