You want a static_cast<int> here --- you're casting a double to an int.