Here you can find the source of doubleToLongBits(double val)
private static long doubleToLongBits(double val)
//package com.java2s; //License from project: Apache License public class Main { private static long doubleToLongBits(double val) { String dbl = String.valueOf(val); int decimpoints = dbl.indexOf(".") > -1 ? dbl.split("\\.")[1].length() : 1; long factor = (long) Math.pow(10, decimpoints); val = val * factor; return Math.round(val); }//from w w w . ja v a2s . co m public static double round(double amount) { double tmp1 = amount; long factor = (long) Math.pow(10, 2); tmp1 = tmp1 * factor; long tmp = Math.round(Math.abs(tmp1)); amount = ((amount < 0 && tmp != 0) ? -1 : 1) * ((double) tmp / factor); String[] strArr = String.valueOf(amount).split("\\."); // // amount = Double.parseDouble(strArr[0] + "." // + (strArr.length > 1 ? strArr[1].substring(0, 2) : "00")); return amount; } }