Conversion of 2 hex numbers into 2 strings and then into a single float?
I need some simple advice...:embarasse
I have a hexadecimal number that is created by two variables, num and dec. where num represent values 0-360 while dec are the decimal values 0-99. The most significant bits are not used in each numbers so I cut these off. For example, if num is f010 and dec = fe02 it means that the total number is 10.02. To print this out I do the following:
sprintf (buff1, "%x", *num);
sprintf (buff2, "%x", *dec);
printf("whole number: %s.%s ", buff1+(strlen(buff1)-3), buff2+(strlen(buff2)-2));
>> whole number: 010.02
Now my problem is to take this number 10.02 and add it to another number.
What is the easiest way to convert this into a float?
Iíve been trying different things but none of them have worked out well. I would be grateful for any input.
Re: Conversion of 2 hex numbers into 2 strings and then into a single float?
float f=(num & 0xff) + float(dec & 0xff)/100.0;
|All times are GMT +5.5. The time now is 05:50.|