Re: Decimal to floating point and floating point to decimal conversion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Amit,

If you want to do this conversion in C, proceed as follows :

#include "stdio.h"
#include "stdlib.h"

int main()
{
float a = 3.2444422 ;
int *p = (int *)(&a) ;
fprintf(stderr,"%08x\n",*p) ;
}

It will print the hex value, which happens to be the same as yours on my machine. To convert opposite way, you need to do the opposite pointer manipulation.

Best Regards,

Henri.
~


On 2023-07-10 12:27, Amit Hiremath via Gcc-help wrote:
Hi,

Can you please point me to codes in GCC where numbers in human readable
format to floating point and floating point to human readable format
conversion are taking place? For example: 3.2444422 -->404FA4F1-->3.2444422

int main ()
{
float a;

a= 3.2444422;

return 0;

}
when you generate asm code, the assembler code is converted to 404FA4F1. So
I am looking for a code in the gcc compiler.

Thanks,
-Amit



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux