In these lines
if(in < 0) return 0;
else if(in == 0) return 1;
Your code is running a comparison between an integer and a float. Specifically 'in < 0' and 'in == 0'. This is generally not going to give you the results you expect for various reasons (see article).
Now, you could cast the value 0 to a float, or change it to '0.0', but that wouldn't really solve your problem.
The real issue is that every time you subtract 0.2 away from the number, it creates a number that is almost but not quite 0.2 less than before. This happens because in c/c++, floating point numbers are represented/stored in their binary form using a standard format known as IEEE Standard for Floating-Point Arithmetic / IEEE 754. And per the article I linked earlier, it is probably not storing the intermediate results as 0.8 -> 0.6 -> 0.4 etc.
You can quickly check what is actually happening by echoing out the values within rec:
#include <limits>
// allows for use of numeric_limits<float>::digits10
// which tells us the precision of
// the floating point number represented in decimal
// without having to know the specifics of the platform.
/*** [omitted code] ***/
int rec(float in){
cout << setprecision(numeric_limits<float>::digits10) << in << ' ' << flush;
/* flush will force the ostream to display to the screen
instead of waiting for the buffer to fill up.
useful if the recursive function never exits for some reason. */
if(in < 0) return 0;
else if(in == 0) return 1;
else return(rec(in-.2));
}
And you should see that the value of 'in' ends up never actually equaling 0, so the bit of code returning 1 is never actually triggered.
The actual values will vary depending on your CPU architecture - I'd love to see what yours prints out.