float variable displaying in hexadecimal format using pointers
Iam trying to display the flaot variable in terms of hexadecimal in byte by byte format.
Is this valid what iam doing here?
Code:
#include<stdio.h>
int main()
{
float fVal = 10.1234;
char *ptr;
int i;
ptr = &fVal;
for(i = 0;i < 4;i++)
{
printf("%02x \n",*ptr);
ptr++;
}
return 0;
}
output:
72
fffffff9
21
41
iam trying to find out the float data variable bit pattern , till now not with much success ( i.e how10.1234 will be converted into bits and kept in that 4 bytes).if any body can find link or tutorial that would be really benificial for me.
thanks for all the help friends