Among other issues that have been addressed by others, a conditional break will never be triggered. y == nan false for each y , including NaN , so the condition is (y == inf && false) , which of course is false .
If you want to break when y is inf or NaN , you should use:
if (isinf(y) || isnan(y)) break;
Or if you want to use comparisons:
if (fabs(y) == inf || y != y) break;
(The fabs is on because you supposedly also want to break if y is -inf .)
source share