Find out whether the bot is rotating left or right

Can you tell me which function can be used to find the exact target, it just shows from -180 to 180 degrees and the transition from positive to negative breaks everything