List of usage examples for java.lang Float floatToRawIntBits
@HotSpotIntrinsicCandidate public static native int floatToRawIntBits(float value);
From source file:Main.java
public static void main(String[] args) { System.out.println("Value = " + Float.floatToRawIntBits(9.0f)); }
From source file:Main.java
static public int setRegAsFloat(int i) { return Float.floatToRawIntBits((float) i); }
From source file:Main.java
/** * Returns next bigger float value considering precision of the argument. * // www. j a v a 2 s .com */ public static float nextUpF(float f) { if (Float.isNaN(f) || f == Float.POSITIVE_INFINITY) { return f; } else { f += 0.0f; return Float.intBitsToFloat(Float.floatToRawIntBits(f) + ((f >= 0.0f) ? +1 : -1)); } }
From source file:Main.java
/** * Creates a {@link IntBuffer} based on the given data. * * @param data the data for the buffer// w w w. ja v a 2 s . co m * @return the int buffer */ public static IntBuffer createIntBuffer(final float[] data) { final int[] tmpData = new int[data.length]; for (int i = 0; i < tmpData.length; i++) { tmpData[i] = Float.floatToRawIntBits(data[i]); } final ByteBuffer bbVertices = ByteBuffer.allocateDirect(tmpData.length * 4); bbVertices.order(ByteOrder.nativeOrder()); final IntBuffer intBuffer = bbVertices.asIntBuffer(); intBuffer.put(tmpData); intBuffer.flip(); return intBuffer; }
From source file:Main.java
public static int floatToIntColor(float value) { return Float.floatToRawIntBits(value); }
From source file:Main.java
public static int floatToRawIntBits(float value) { return Float.floatToRawIntBits(value); }
From source file:Main.java
public static void fromFloat(byte[] bytes, float value, int offset) { fromInt(bytes, Float.floatToRawIntBits(value), offset); }
From source file:Main.java
/** * Returns unbiased exponent of a <code>float</code>. *///from ww w .j a v a2 s .c o m public static int getExponent(float f) { /* * Bitwise convert f to integer, mask out exponent bits, shift * to the right and then subtract out float's bias adjust to * get true exponent value */ return ((Float.floatToRawIntBits(f) & FloatConsts.EXP_BIT_MASK) >> (FloatConsts.SIGNIFICAND_WIDTH - 1)) - FloatConsts.EXP_BIAS; }
From source file:Main.java
public static byte[] toByta(float data) { return toByta(Float.floatToRawIntBits(data)); }
From source file:Main.java
/** * Returns the floating-point value adjacent to <code>f</code> in * the direction of positive infinity. This method is * semantically equivalent to <code>nextAfter(f, * Double.POSITIVE_INFINITY)</code>; however, a <code>nextUp</code> * implementation may run faster than its equivalent * <code>nextAfter</code> call. * * <p>Special Cases:/*from w w w. j a v a 2 s. com*/ * <ul> * <li> If the argument is NaN, the result is NaN. * * <li> If the argument is positive infinity, the result is * positive infinity. * * <li> If the argument is zero, the result is * <code>Float.MIN_VALUE</code> * * </ul> * * @param f starting floating-point value * @return The adjacent floating-point value closer to positive * infinity. * @author Joseph D. Darcy */ public static float nextUp(float f) { if (isNaN(f) || f == FloatConsts.POSITIVE_INFINITY) return f; else { f += 0.0f; return Float.intBitsToFloat(Float.floatToRawIntBits(f) + ((f >= 0.0f) ? +1 : -1)); } }