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

后端 未结 11 2109
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:07

    You may be interested in the Game Developers Conference lecture Numerical Robustness for Geometric Calculations (aka EPSILON is NOT 0.00001!). It details choosing good threshold / epsilon values for a variety of tasks.

    (+1 on the mention of "What Every Computer Scientist Should Know About Floating Point" in another answer, too.)

提交回复
热议问题