Java examples for java.lang:double Array
Puts the IEEE representation of the double provided into the array at the designated position
/*/* w ww .j a v a 2 s . com*/ * Copyright (c) 2007-2016 AREasy Runtime * * This library, AREasy Runtime and API for BMC Remedy AR System, is free software ("Licensed 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 2.1 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; * including but not limited to, the implied warranty of MERCHANTABILITY, NONINFRINGEMENT, * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. */ //package com.java2s; public class Main { /** * Puts the IEEE representation of the double provided into the array * at the designated position * * @param target the data block into which the binary representation is to * be placed * @param pos the position in target in which to place the bytes * @param d the double value to convert to raw bytes */ public static void getIEEEBytes(double d, byte[] target, int pos) { long val = Double.doubleToLongBits(d); target[pos] = (byte) (val & 0xff); target[pos + 1] = (byte) ((val & 0xff00) >> 8); target[pos + 2] = (byte) ((val & 0xff0000) >> 16); target[pos + 3] = (byte) ((val & 0xff000000) >> 24); target[pos + 4] = (byte) ((val & 0xff00000000L) >> 32); target[pos + 5] = (byte) ((val & 0xff0000000000L) >> 40); target[pos + 6] = (byte) ((val & 0xff000000000000L) >> 48); target[pos + 7] = (byte) ((val & 0xff00000000000000L) >> 56); } }