Floating point numbers aren't accurate.
You can try dividing one by N, in the next line multiply again by N, and check for 1.
It may fail for N=3 or N=10 or many others, as 1/3 and 1/10 cannot be represented exactly in binary floating point notation. 1/2, 1/4, 1/8 can, but 1/3, 1/5, 1/10 can't.
Note: even when (1.0/3.0)*3.0 may be printed as 1, that does not mean it is exactly one; the convert-to-string routines are somewhat 'forgiving'.
Therefore, you should not apply an equality test to floating point numbers, instead allow for some tolerance, as in:
if (abs(currentValue-expectedValue) < epsilon ) ...
where epsilon is some small value, i.e. small with respect to expectedValue.
Note2: if you make epsilon too small, your algorithm may never converge... and that is what you are experiencing right now, as your code basically has epsilon equal to zero.
PS: all of the above applies to all languages I know, it is not specific to C++.