java.lang.Double toHexString(double d)

Syntax:

public static String toHexString(double d)

Java Code Example :

This java example source code demonstrates the use of toHexString(double d) method of Double class.  Basically we just get the hexadecimal String representation of the double input argument . The method toHexString(double d) must be invoked statically.

package com.javatutorialhq.java.examples;

/*
 * This example source code demonstrates the use of static method
 * toHexString(double d) of Double class
 */

public class DoubleToHexStringDouble {

	public static void main(String[] args) {
		double d = 189.35;
		// convert to hexadecimal String equivalent
		String str = Double.toHexString(d);
		System.out.println("Hex String equivalent:" + str);

		// try another value
		double d2 = -101.3439832;
		System.out.println("Second value:" + Double.toHexString(d2));

		/*
		 * Make note that the second input is a negative value
		 */

	}

}

Sample Output :

Running the above example source code will give the following output

Double toHexString(double d) method example

Double toHexString(double d) method example

Suggested Reading List :

References :