Here you can find the source of swapFloat(float floatValue)
Parameter | Description |
---|---|
floatValue | the float to swap |
public static float swapFloat(float floatValue)
//package com.java2s; /*//from ww w .jav a 2 s .co m * Copyright 1999-2002 Carnegie Mellon University. * Portions Copyright 2002 Sun Microsystems, Inc. * Portions Copyright 2002 Mitsubishi Electric Research Laboratories. * All Rights Reserved. Use is subject to license terms. * * See the file "license.terms" for information on usage and * redistribution of this file, and for a DISCLAIMER OF ALL * WARRANTIES. * */ public class Main { /** * Byte-swaps the given float to the other endian. That is, if this float is big-endian, it becomes little-endian, * and vice-versa. * * @param floatValue the float to swap */ public static float swapFloat(float floatValue) { return Float.intBitsToFloat(swapInteger(Float .floatToRawIntBits(floatValue))); } /** * Byte-swaps the given integer to the other endian. That is, if this integer is big-endian, it becomes * little-endian, and vice-versa. * * @param integer the integer to swap */ public static int swapInteger(int integer) { return (((0x000000ff & integer) << 24) | ((0x0000ff00 & integer) << 8) | ((0x00ff0000 & integer) >> 8) | ((0xff000000 & integer) >> 24)); } }