How do I calculate the difference of two angle measures?

In addition to Nickes answer, if u want "Signed difference"

int d = Math.abs(a - b) % 360; 
int r = d > 180 ? 360 - d : d;

//calculate sign 
int sign = (a - b >= 0 && a - b <= 180) || (a - b <=-180 && a- b>= -360) ? 1 : -1; 
r *= sign;

EDITED:

Where 'a' and 'b' are two angles to find the difference of.

'd' is difference. 'r' is result / final difference.


    /**
     * Shortest distance (angular) between two angles.
     * It will be in range [0, 180].
     */
    public static int distance(int alpha, int beta) {
        int phi = Math.abs(beta - alpha) % 360;       // This is either the distance or 360 - distance
        int distance = phi > 180 ? 360 - phi : phi;
        return distance;
    }