Java Double to Byte Array doubleToBytes(double d)

Here you can find the source of doubleToBytes(double d)

Description

double To Bytes

License

Open Source License

Declaration

public static byte[] doubleToBytes(double d) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2013 Oak Ridge National Laboratory.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 ******************************************************************************/

public class Main {
    public static byte[] doubleToBytes(double d) {
        long l = Double.doubleToRawLongBits(d);
        byte[] r = new byte[8];
        for (int i = 0; i < 8; i++) {
            r[i] = (byte) ((l >>> (i * 8)) & 0xFF);
        }//from  w w w.  j a  v a  2  s.  com
        return r;
    }
}

Related

  1. doubleToByteArray(double source)
  2. doubleToByteArray(double value)
  3. doubleToByteArrayBE(double data)
  4. doubleToBytes(double d)
  5. doubleToBytes(double d)
  6. doubleToBytes(double d, byte[] bytes, int off, boolean bigEndian)
  7. doubleToBytes(double d, byte[] data, int[] offset)
  8. doubleToBytes(double dnum, byte[] bytes, int startIndex)
  9. doubleToBytes(double v, byte[] bytes)