Java Number Swap swapFloat(float value)

Here you can find the source of swapFloat(float value)

Description

Reverses the byte order of the source float value

License

Apache License

Parameter

Parameter Description
value the source value

Return

the converted value

Declaration

public static float swapFloat(float value) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**//from   w  w  w . ja  v a 2s. co  m
     * Reverses the byte order of the source <tt>float</tt> value
     * @param value the source value
     * @return the converted value
     */
    public static float swapFloat(float value) {
        int i = Float.floatToIntBits(value);
        i = swapInteger(i);
        return Float.intBitsToFloat(i);
    }

    /**
     * Reverses the byte order of the source <tt>int</tt> value
     * @param value the source value
     * @return the converted value
     */
    public static int swapInteger(int value) {
        return ((value & 0xFF000000) >> 24) | ((value & 0x00FF0000) >> 8) | ((value & 0x0000FF00) << 8)
                | ((value & 0x000000FF) << 24);
    }
}

Related

  1. swapBytes(final int i)
  2. swapCasing(String str)
  3. swapDouble(double value)
  4. swapDouble(double value)
  5. swapFloat(float floatValue)
  6. swapInt(int i)
  7. swapInt(int i)
  8. swapInteger(int integer)
  9. swapLong(long value)