Here you can find the source of swapBytes(final int i)
Parameter | Description |
---|---|
i | the integer value to swap |
i
.
public static int swapBytes(final int i)
//package com.java2s; /*//w w w.j a v a 2s .co m * Copyright (c) 2014 Stephan D. Cote' - All rights reserved. * * This program and the accompanying materials are made available under the * terms of the MIT License which accompanies this distribution, and is * available at http://creativecommons.org/licenses/MIT/ * * Contributors: * Stephan D. Cote * - Initial API and implementation */ public class Main { /** * Swap bytes * * @param s the short value to swap * * @return The byte swapped version of <code>s</code>. */ public static short swapBytes(final short s) { return (short) ((s << 8) | ((s >> 8) & 0x00ff)); } /** * Swap bytes * * @param i the integer value to swap * * @return The byte swapped version of <code>i</code>. */ public static int swapBytes(final int i) { return (i << 24) | ((i << 8) & 0x00ff0000) | (i >>> 24) | ((i >> 8) & 0x0000ff00); } }