Floating point conversion in STM32f767.
Hello Everyone,
I am using STM32F767 and have generated code from STM32CubeMX. I am trying to convert a string of hexadecimal to float value, but it seems that the float is not converting the value. I am using Keil IDE UV5 ,and I have tried setting "Floating point hardware" in Target options with "Not used", "Single precision" as well as "Double precision", but nothing seems to work. Am I missing something? or is anything needed to be done so that "float" conversion works?
My code is as follows:-
char val[20];float f;
uint32_t num;
sprintf(val,"%02x%02x%02x%02x",0x43,0x71,0x3E,0xE9);
printf("val is %s\n\r",val);
sscanf(val,"%x",&num);
printf("num %x -- %d\n\r",num,num);
f = *((float*)&num);
f = ((float)num);
printf("float is %.2f\n\r",f);
This prints "float is 1131495145.00" whereas it should be "241.245743"
Help will be appreciated.
Thank you.
