Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to convert decimal numbers into IEEE 32-bit floating-point numbers? It would be better if it can be realized in C language! Thank you, Wulin heroes!
How to convert decimal numbers into IEEE 32-bit floating-point numbers? It would be better if it can be realized in C language! Thank you, Wulin heroes!
Convert integers to 32-bit floating-point numbers? If system forced transmission is used, the pure C code is as follows:

# include & ltstdio.h & gt

int main()

{

Floating test = 0.0f

int after = 0;

int I = 0;

char * b = 0;

Scanf("%d ",after &); //Enter the plastic to be converted.

After test =; //Forced to be converted to floating point by the system.

b =(char *)& amp; Testing; //Forced conversion, so that the character pointer points to floating point, so that its bytes can be output below.

for(I = sizeof(test)- 1; I & gt=0; I-)// Single precision ***4 bytes

{

printf("%x ",int(b[I])); //Output the contents of each byte. 16 base.

If(int(b[i])==0)// If the integer value of byte conversion is 0, add another zero, because a byte needs to output a hexadecimal number of 2 bits 16.

printf(" 0 ");

}

Returns 0;

}