Aug 15, 2008 17:56
I am writing a program that takes a decimal number and converts it to hex. The input can be int or float. Now, I got it to convert int to hex but I can't convert the float to hex. It's dropping the fraction completely and just using whatever is to the left of the decimal point.
any suggestions?
Leave a comment
Comments 7
If so, separate the float into 2 parts, the integer part and the fractional part, and multiply the fractional part by a large enough power of 10 to convert it to an integer, then convert both to hex and print them out appended with the decimal point in between.
Reply
Reply
Reply
Reply
Reply
Reply
Leave a comment