get the integer representation value of a float type variable in C

前端 未结 6 1931
悲哀的现实
悲哀的现实 2020-12-21 13:19

I have the number 20 (0x14) stored in a 32-bit register. The register is allocated to a C float variable representing the value 2.8e-44. Now I want to get the hexadecimal re

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-21 13:53

    What are you doing there is Undefined Behavior, didn't you check the warning?

    warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘double’ [-Wformat=]
         printf("n=%d\n",f);
         ^
    

    Read this please: How do the digits 1101004800 correspond with the number 20?

提交回复
热议问题