Java Bit Flip flip(int i)

Here you can find the source of flip(int i)

Description

Flips the byte order of an integer

License

Apache License

Parameter

Parameter Description
i the integer

Return

the flipped integer

Declaration

public static int flip(int i) 

Method Source Code

//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

public class Main {
    /**/*w w w .jav a 2 s  . c  o  m*/
     * Flips the byte order of an integer
     * @param i the integer
     * @return the flipped integer
     */
    public static int flip(int i) {
        int result = 0;
        result |= (i & 0xFF) << 24;
        result |= (i & 0xFF00) << 8;
        result |= ((i & 0xFF0000) >> 8) & 0xFF00;
        result |= ((i & 0xFF000000) >> 24) & 0xFF;
        return result;
    }
}

Related

  1. flip(int value)
  2. flip(long a)
  3. flipBitAsBinaryString(int flipBit)
  4. flipBitAt(int bitIndex, byte b)