I intend to write a GUI java program which convert a decimal(base 10) to hexadecimal(base 16). Floating point decimals are also valid input. the code of my program
private void myEnterButtonActionPerformed(java.awt.event.ActionEvent evt) {
float mynum;
mynum = Float.parseFloat(this.myNumberField.getText());
Float floatObject = Float.valueOf(mynum);
myResultField.setText(Float.toHexString(mynum));
}
but when I run the program, the input of 12.9 gives 0x1.9cccccp3, whereas I want the output as C.E6666
Help me to solve this problem.