Should work:

player.pan = ang(player.pan);
if (player.pan < 0) player.pan += 360;