Java Double to Byte Array double2bytes(double v, int len)

Here you can find the source of double2bytes(double v, int len)

Description

doublebytes

License

Apache License

Declaration

public static byte[] double2bytes(double v, int len) 

Method Source Code

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

public class Main {
    public static byte[] double2bytes(double v, int len) {
        byte[] b = new byte[len];
        long l = Double.doubleToLongBits(v);
        for (int i = 0; i < len && i < 8; i++) {
            b[i] = new Long(l).byteValue();
            l = l >> 8;// w  w  w  .  j  ava  2s  . co  m
        }
        return b;
    }
}

Related

  1. double2bytearray(double rastervalue)
  2. double2bytes(double v)
  3. double2bytes(double v, byte[] b)
  4. double2bytes(double value)
  5. double2bytes(double x)
  6. double2bytesLE(double val, byte[] b, int off)
  7. doubleToByteArray(double d)