Java Double to Byte Array putDouble(byte[] b, double val)

Here you can find the source of putDouble(byte[] b, double val)

Description

put Double

License

Open Source License

Declaration

static void putDouble(byte[] b, double val) 

Method Source Code

//package com.java2s;
/*//from w  w w .  ja  v a  2  s .c o m
 *  Copyright (C) 2013, Peter Decsi.
 * 
 *  This library is free software: you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public 
 *  License as published by the Free Software Foundation, either 
 *  version 3 of the License, or (at your option) any later version.
 * 
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    static void putDouble(byte[] b, double val) {
        long j = Double.doubleToLongBits(val);
        b[7] = (byte) (j >>> 0);
        b[6] = (byte) (j >>> 8);
        b[5] = (byte) (j >>> 16);
        b[4] = (byte) (j >>> 24);
        b[3] = (byte) (j >>> 32);
        b[2] = (byte) (j >>> 40);
        b[1] = (byte) (j >>> 48);
        b[0] = (byte) (j >>> 56);
    }
}

Related

  1. doubleToBytes(double v, byte[] bytes, int off)
  2. doubleToBytes(double value)
  3. doubleToBytes(final double d)
  4. doubleToBytes(final double val)
  5. DoubleToBytes_With_Little_Endian(double number)
  6. putDouble(byte[] data, int i, boolean le, double v)
  7. putDouble(double x)