Strange behavior when casting an int to float in C

前端 未结 5 1733
予麋鹿
予麋鹿 2021-02-18 14:27

I have a doubt concerning the output of the following C program. I tried to compile it using both Visual C++ 6.0 and MinGW32 (gcc 3.4.2).

#include 

        
5条回答
  •  失恋的感觉
    2021-02-18 14:54

    On the first printf, the conversion from integer to float is done by the compiler. On the second one, it is done by the C runtime library. There is no particular reason why they should produce answers identical at the limits of their precision.

提交回复
热议问题