/** * Gets the current value. * * @return the current value */ public final double get() { return longBitsToDouble(value); }
static double scaleNormalize(double x) { long significand = doubleToRawLongBits(x) & SIGNIFICAND_MASK; return longBitsToDouble(significand | ONE_BITS); }
/** * Atomically sets to the given value and returns the old value. * * @param newValue the new value * @return the previous value */ public final double getAndSet(double newValue) { long next = doubleToRawLongBits(newValue); return longBitsToDouble(updater.getAndSet(this, next)); }
/** * Gets the current value at position {@code i}. * * @param i the index * @return the current value */ public final double get(int i) { return longBitsToDouble(longs.get(i)); }
/** * Atomically sets the element at position {@code i} to the given value and returns the old value. * * @param i the index * @param newValue the new value * @return the previous value */ public final double getAndSet(int i, double newValue) { long next = doubleToRawLongBits(newValue); return longBitsToDouble(longs.getAndSet(i, next)); }
/** * Parses a 64-bit double value from the stream. * <p> * <pre> * b64 b56 b48 b40 b32 b24 b16 b8 * </pre> */ private double parseDouble() throws IOException { long bits = parseLong(); return Double.longBitsToDouble(bits); }
/** * Gets a 64-bit floating point number at the current {@code readerIndex} * in Little Endian Byte Order and increases the {@code readerIndex} * by {@code 8} in this buffer. * * @throws IndexOutOfBoundsException * if {@code this.readableBytes} is less than {@code 8} */ public double readDoubleLE() { return Double.longBitsToDouble(readLongLE()); }
@Override public double getDouble(int index) { return Double.longBitsToDouble(getLong(index)); }
@Override public double readDouble() throws IOException { return Double.longBitsToDouble(readLong()); }
@Override public double getDouble(int index) { return Double.longBitsToDouble(getLong(index)); }
/** * Gets a 64-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 + 8} is greater than {@code this.capacity} */ public double getDoubleLE(int index) { return Double.longBitsToDouble(getLongLE(index)); }
@Override public final double getDouble(int index) { return Double.longBitsToDouble(getLong(index)); }
@Override public double readDouble() { return Double.longBitsToDouble(readLong()); }
/** * Reads a "double" value from an InputStream. The value is * converted to the opposed endian system while reading. * @param input source InputStream * @return the value just read * @throws IOException in case of an I/O problem */ public static double readSwappedDouble(final InputStream input) throws IOException { return Double.longBitsToDouble( readSwappedLong( input ) ); }
/** * Reads a {@code double} as specified by {@link DataInputStream#readDouble()}, except using * little-endian byte order. * * @return the next eight bytes of the input stream, interpreted as a {@code double} in * little-endian byte order * @throws IOException if an I/O error occurs */ @CanIgnoreReturnValue // to skip some bytes @Override public double readDouble() throws IOException { return Double.longBitsToDouble(readLong()); }
private void initializeData(DataOutputStream out) throws IOException { /* Write out various test values NORMALLY */ out.write(new byte[] {-100, 100}); out.writeBoolean(true); out.writeBoolean(false); out.writeByte(100); out.writeByte(-100); out.writeByte((byte) 200); out.writeChar('a'); out.writeShort((short) -30000); out.writeShort((short) 50000); out.writeInt(0xCAFEBABE); out.writeLong(0xDEADBEEFCAFEBABEL); out.writeUTF("Herby Derby"); out.writeFloat(Float.intBitsToFloat(0xCAFEBABE)); out.writeDouble(Double.longBitsToDouble(0xDEADBEEFCAFEBABEL)); }
public void testDouble() { TestHasher hasher = new TestHasher(); hasher.putDouble(Double.longBitsToDouble(0x0807060504030201L)); hasher.assertBytes(new byte[] {1, 2, 3, 4, 5, 6, 7, 8}); }
public void testNewDataInput_readDouble() { byte[] data = {0x12, 0x34, 0x56, 0x78, 0x76, 0x54, 0x32, 0x10}; ByteArrayDataInput in = ByteStreams.newDataInput(data); assertEquals(Double.longBitsToDouble(0x1234567876543210L), in.readDouble(), 0.0); }
public void testNewDataOutput_writeDouble() { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeDouble(Double.longBitsToDouble(0x1234567876543210L)); assertEquals(bytes, out.toByteArray()); }
public void testDouble() { Sink sink = new Sink(8); sink.putDouble(Double.longBitsToDouble(0x0807060504030201L)); HashCode unused = sink.hash(); sink.assertInvariants(8); sink.assertBytes(new byte[] {1, 2, 3, 4, 5, 6, 7, 8}); }