Here you can find the source of doubleToByte(double d)
public static byte[] doubleToByte(double d)
//package com.java2s; //License from project: Apache License public class Main { public static byte[] doubleToByte(double d) { long x = Double.doubleToLongBits(d); if ((x & 0xFFFFFFFFFFFFFF00L) == 0L) { return new byte[] { (byte) x }; } else if ((x & 0xFFFFFFFFFFFF0000L) == 0L) { return new byte[] { (byte) (x >> 8), (byte) x }; } else if ((x & 0xFFFFFFFFFF000000L) == 0L) { return new byte[] { (byte) (x >> 16), (byte) (x >> 8), (byte) x }; } else if ((x & 0xFFFFFFFF00000000L) == 0L) { return new byte[] { (byte) (x >> 24), (byte) (x >> 16), (byte) (x >> 8), (byte) x }; } else if ((x & 0xFFFFFF0000000000L) == 0L) { return new byte[] { (byte) (x >> 32), (byte) (x >> 24), (byte) (x >> 16), (byte) (x >> 8), (byte) x }; } else if ((x & 0xFFFF000000000000L) == 0L) { return new byte[] { (byte) (x >> 40), (byte) (x >> 32), (byte) (x >> 24), (byte) (x >> 16), (byte) (x >> 8), (byte) x }; } else if ((x & 0xFF00000000000000L) == 0L) { return new byte[] { (byte) (x >> 48), (byte) (x >> 40), (byte) (x >> 32), (byte) (x >> 24), (byte) (x >> 16), (byte) (x >> 8), (byte) x }; }/* w ww .ja v a 2 s .c o m*/ return new byte[] { (byte) (x >> 56), (byte) (x >> 48), (byte) (x >> 40), (byte) (x >> 32), (byte) (x >> 24), (byte) (x >> 16), (byte) (x >> 8), (byte) x }; } }