java.lang.Double.longBitsToDouble()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(212)

本文整理了Java中java.lang.Double.longBitsToDouble()方法的一些代码示例,展示了Double.longBitsToDouble()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Double.longBitsToDouble()方法的具体详情如下:
包路径:java.lang.Double
类名称:Double
方法名:longBitsToDouble

Double.longBitsToDouble介绍

[英]Returns the IEEE 754 double precision float corresponding to the given bits.
[中]返回与给定位对应的IEEE 754双精度浮点。

代码示例

代码示例来源:origin: google/guava

/**
 * Gets the current value.
 *
 * @return the current value
 */
public final double get() {
 return longBitsToDouble(value);
}

代码示例来源:origin: google/guava

static double scaleNormalize(double x) {
 long significand = doubleToRawLongBits(x) & SIGNIFICAND_MASK;
 return longBitsToDouble(significand | ONE_BITS);
}

代码示例来源:origin: google/guava

/**
 * 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));
}

代码示例来源:origin: google/guava

/**
 * 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));
}

代码示例来源:origin: google/guava

/**
 * 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));
}

代码示例来源:origin: apache/incubator-dubbo

/**
 * 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);
}

代码示例来源:origin: netty/netty

/**
 * 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());
}

代码示例来源:origin: netty/netty

@Override
public double getDouble(int index) {
  return Double.longBitsToDouble(getLong(index));
}

代码示例来源:origin: netty/netty

@Override
public double readDouble() throws IOException {
  return Double.longBitsToDouble(readLong());
}

代码示例来源:origin: netty/netty

@Override
public double getDouble(int index) {
  return Double.longBitsToDouble(getLong(index));
}

代码示例来源:origin: netty/netty

/**
 * 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));
}

代码示例来源:origin: netty/netty

@Override
public final double getDouble(int index) {
  return Double.longBitsToDouble(getLong(index));
}

代码示例来源:origin: netty/netty

@Override
public double readDouble() {
  return Double.longBitsToDouble(readLong());
}

代码示例来源:origin: commons-io/commons-io

/**
 * 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 ) );
}

代码示例来源:origin: google/guava

/**
 * 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());
}

代码示例来源:origin: google/guava

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));
}

代码示例来源:origin: google/guava

public void testDouble() {
 TestHasher hasher = new TestHasher();
 hasher.putDouble(Double.longBitsToDouble(0x0807060504030201L));
 hasher.assertBytes(new byte[] {1, 2, 3, 4, 5, 6, 7, 8});
}

代码示例来源:origin: google/guava

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);
}

代码示例来源:origin: google/guava

public void testNewDataOutput_writeDouble() {
 ByteArrayDataOutput out = ByteStreams.newDataOutput();
 out.writeDouble(Double.longBitsToDouble(0x1234567876543210L));
 assertEquals(bytes, out.toByteArray());
}

代码示例来源:origin: google/guava

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});
}

相关文章