Java Double to Byte Array doubleToByteArray(double number)

Here you can find the source of doubleToByteArray(double number)

Description

double to byte array

License

Apache License

Parameter

Parameter Description
number a parameter

Return

byte[]

Declaration

public static byte[] doubleToByteArray(double number) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/*  w ww .  ja  v a 2 s.  com*/
     * double to byte array
     * 
     * @param number
     * @return byte[]
     */
    public static byte[] doubleToByteArray(double number) {
        byte[] byteArray = new byte[8];
        long longBits = Double.doubleToLongBits(number);
        for (int i = 0; i < byteArray.length; i++) {
            byteArray[i] = new Long(longBits).byteValue();
            longBits = longBits >> 8;
        }
        return byteArray;
    }
}

Related

  1. double2bytes(double v, int len)
  2. double2bytes(double value)
  3. double2bytes(double x)
  4. double2bytesLE(double val, byte[] b, int off)
  5. doubleToByteArray(double d)
  6. doubleToByteArray(double source)
  7. doubleToByteArray(double value)
  8. doubleToByteArrayBE(double data)
  9. doubleToBytes(double d)