Why Isn't My Floating Point Values Printing Properly?

前端 未结 4 2015
-上瘾入骨i
-上瘾入骨i 2021-01-24 07:50

I am trying to print out the floating point values 0x40a00000 and 0xc0200000. But the values that I print out and the correct values according to the IEEE-754 Floating Point Con

4条回答
  •  星月不相逢
    2021-01-24 08:38

    union
    {
       int i;
       float f;
    }k1,k2;
    
    k1.i = 0x40a00000;
    k2.i = 0xc0200000;
    
    printf("f1 = %.2f\n", k1.f);
    printf("f2 = %.2f\n", k2.f);
    

提交回复
热议问题