I see the problem: Your number of steps exceeds the size of an int. Make numberOfSteps a const unsigned int.