The operations and representations of floating point numbers and integers in C language are different. This statement is very loose, so how to judge depends on your own definition.
My understanding is that if a floating point number can be divided into an integer part and a decimal part, then you want to judge whether a floating point number is basically the same as its integer part. Strictly speaking, the error is very small.
In this case, you can write like this:
double err = 1e-10; //define the error yourself first
x = 2.9999999997;
if (abs( int(x)-x) ...