Here you can find the source of convertDoubleIntoHexadecimalString(double value, int precision)
public static String convertDoubleIntoHexadecimalString(double value, int precision)
//package com.java2s; //License from project: Apache License public class Main { public static String convertDoubleIntoHexadecimalString(double value, int precision) { double fractionValue = value % 1; int intValue = (int) (value - fractionValue); String str = Integer.toHexString(intValue); if (fractionValue != 0) { str += "."; StringBuilder dec = new StringBuilder(); while ((fractionValue *= 16) != 0 && dec.length() < precision) { double temp = fractionValue % 1; intValue = (int) (fractionValue - temp); fractionValue = temp;//from www. j av a 2 s.c o m dec.append(Integer.toHexString(intValue)); } str += dec; } return str; } }