This will give a signed angle diff between two angles.
angle(0,0,cos(a-b),sin(a-b))
It's in the range of -180 to 180. It always picks the shortest distance but it's negative if CCW and positive if CW.
Alternatively you could leverage the CW and CCW conditions or calculate if the angle diff is CW or CCW with
(sin(a-b)<0?-1:1)
global sign=1
global short_angdiff=0
global long_angdiff=0
every tick
--- set sign to (sin(a-b)<0?-1:1)
--- set short_angdiff to anglediff(a,b)*sign
--- set long_angdiff to (360-anglediff(a,b))*-1*sign