Java ByteBuffer Get getDouble(ByteBuffer buffer)

Here you can find the source of getDouble(ByteBuffer buffer)

Description

get Double

License

Open Source License

Declaration

public static double getDouble(ByteBuffer buffer) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.nio.ByteBuffer;

public class Main {
    public static double getDouble(ByteBuffer buffer) {

        assert (buffer.capacity() - buffer.position() >= 8);

        long[] data = new long[8];

        data[7] = buffer.get();/*from  w ww  .  j ava  2  s.co m*/
        data[6] = buffer.get();
        data[5] = buffer.get();
        data[4] = buffer.get();
        data[3] = buffer.get();
        data[2] = buffer.get();
        data[1] = buffer.get();
        data[0] = buffer.get();

        return Double
                .longBitsToDouble(((data[0] << 56) & 0xff00000000000000l) | ((data[1] << 48) & 0x00ff000000000000l)
                        | ((data[2] << 40) & 0x0000ff0000000000l) | ((data[3] << 32) & 0x000000ff00000000l)
                        | ((data[4] << 24) & 0x00000000ff000000l) | ((data[5] << 16) & 0x0000000000ff0000l)
                        | ((data[6] << 8) & 0x000000000000ff00l) | (data[7] & 0x00000000000000ffl));
    }
}

Related

  1. getCRLFIndex(ByteBuffer buffer)
  2. getCRLFLine(ByteBuffer buf)
  3. getData(ByteBuffer buf, int index, int size)
  4. getDataFromBuffer(ByteBuffer b)
  5. getDirectByteBuffer(ByteBuffer var0, boolean var1)
  6. getDoubleArray(ByteBuffer buffer, int numDoubles)
  7. getDoubleFromByteBuffer(ByteBuffer data)
  8. getEmptyByteBuffer()
  9. getFixedBytes(ByteBuffer buffer, int length)