Is relational comparison between int and float directly possible in C?

后端 未结 11 2124
Happy的楠姐
Happy的楠姐 2020-12-03 18:48

I am using Visual Studio 6 with some old time code written in c. I found an issue where the code looks like this..

int x = 3;
float y = 3.0;

if(x == y){
            


        
11条回答
  •  余生分开走
    2020-12-03 19:25

    The crux of the problem is that floating point numbers which have a finite representation in base 10, decimal don't always have a finite representation in base 2, binary.

提交回复
热议问题