/** Converts the color from a float ABGR encoding to an int ABGR encoding. The alpha is expanded from 0-254 in the float * encoding (see {@link #intToFloatColor(int)}) to 0-255, which means converting from int to float and back to int can be * lossy. */ public static int floatToIntColor (float value) { int intBits = Float.floatToRawIntBits(value); intBits |= (int)((intBits >>> 24) * (255f / 254f)) << 24; return intBits; }
/** Converts the color from a float ABGR encoding to an int ABGR encoding. The alpha is expanded from 0-254 in the float * encoding (see {@link #intToFloatColor(int)}) to 0-255, which means converting from int to float and back to int can be * lossy. */ public static int floatToIntColor (float value) { int intBits = Float.floatToRawIntBits(value); intBits |= (int)((intBits >>> 24) * (255f / 254f)) << 24; return intBits; }
@Override public byte[] serialize(final String topic, final Float data) { if (data == null) return null; long bits = Float.floatToRawIntBits(data); return new byte[] { (byte) (bits >>> 24), (byte) (bits >>> 16), (byte) (bits >>> 8), (byte) bits }; }
public static int floatToRawIntBits (float value) { return Float.floatToRawIntBits(value); }
public static int floatToRawIntBits (float value) { return Float.floatToRawIntBits(value); }
/** * Adds a CONSTANT_Float_info to the constant pool of this symbol table. Does nothing if the * constant pool already contains a similar item. * * @param value a float. * @return a new or already existing Symbol with the given value. */ Symbol addConstantFloat(final float value) { return addConstantIntegerOrFloat(Symbol.CONSTANT_FLOAT_TAG, Float.floatToRawIntBits(value)); }
@Override public final Hasher putFloat(float f) { return putInt(Float.floatToRawIntBits(f)); }
@Override public ByteBuf setFloat(int index, float value) { setInt(index, Float.floatToRawIntBits(value)); return this; }
@Override public final ByteBuf writeFloat(float value) { writeInt(Float.floatToRawIntBits(value)); return this; }
@Override public ByteBuf writeFloat(float value) { writeInt(Float.floatToRawIntBits(value)); return this; }
/** * Sets the specified 32-bit floating point number at the current * {@code writerIndex} in Little Endian Byte Order and increases * the {@code writerIndex} by {@code 4} in this buffer. * If {@code this.writableBytes} is less than {@code 4}, {@link #ensureWritable(int)} * will be called in an attempt to expand capacity to accommodate. */ public ByteBuf writeFloatLE(float value) { return writeIntLE(Float.floatToRawIntBits(value)); }
@Override public final ByteBuf setFloat(int index, float value) { setInt(index, Float.floatToRawIntBits(value)); return this; }
@Override public ByteBuf setFloat(int index, float value) { setInt(index, Float.floatToRawIntBits(value)); return this; }
@Override public ByteBuf writeFloat(float value) { writeInt(Float.floatToRawIntBits(value)); return this; }
@Override public CompositeByteBuf writeFloat(float value) { super.writeInt(Float.floatToRawIntBits(value)); return this; }
/** * Sets the specified 32-bit floating-point number at the specified * absolute {@code index} in this buffer in Little Endian Byte Order. * This method does not modify {@code readerIndex} or {@code writerIndex} of * this buffer. * * @throws IndexOutOfBoundsException * if the specified {@code index} is less than {@code 0} or * {@code index + 4} is greater than {@code this.capacity} */ public ByteBuf setFloatLE(int index, float value) { return setIntLE(index, Float.floatToRawIntBits(value)); }
@Override public CompositeByteBuf setFloat(int index, float value) { return setInt(index, Float.floatToRawIntBits(value)); }
@ScalarOperator(CAST) @SqlType(StandardTypes.REAL) public static long castToReal(@SqlType(StandardTypes.BOOLEAN) boolean value) { return value ? floatToRawIntBits(1.0f) : floatToRawIntBits(0.0f); }
@ScalarOperator(ADD) @SqlType(StandardTypes.REAL) public static long add(@SqlType(StandardTypes.REAL) long left, @SqlType(StandardTypes.REAL) long right) { return floatToRawIntBits(intBitsToFloat((int) left) + intBitsToFloat((int) right)); }
public static Block createSequenceBlockOfReal(int start, int end) { BlockBuilder builder = REAL.createFixedSizeBlockBuilder(end - start); for (int i = start; i < end; i++) { REAL.writeLong(builder, floatToRawIntBits((float) i)); } return builder.build(); }