Sorry for the long title. Whenever the rotation of the object exceeds 180(degrees) when the rotation is supposed to be 350 its -10, 340 = -20, 330 = -30, and so on.
const float PI = 3.14159265;
int mx = sf::Mouse::getPosition(window).x;
int my = sf::Mouse::getPosition(window).y;
int tmp_rot = (atan2(my - y, mx - x)) * 180 / PI;
rot = tmp_rot;