`sr -float(sr)`

evaluates to. It's not zero, bet very close. On my system I get 4.44089e-16. Why would that be. This has to do with how computers represent floating point numbers (float, double, long double). In particular, some base-10 numbers cannot be represented to 100% accuracy. There is also the limitation of the precision of floating point numbers. As an example, in base-10 even 1.0/3.0 cannot be represented accurately, so the calculation (1.0/3.0)*3.0 expressed to 10 digits of precision returns 0.999999999, not 1.0. Combine those 2 things together and often times what we expect to happen when working with floating point numbers is wrong, when dealing with computers. In particular, comparison for equality, as shown here, doesn't always work as expected. In general, you'll want to know how accurate you need to be and compare within that accuracy. You might, for example, use this` return( fabs(sr - floor(sr)) < 1e-6)`

instead of a comparison against 0.0