How to formulate calculation to find if two numbers are within difference of 10 units.
B and C are within 10 units difference from A. D is not.
Find the difference between the other points and point A = 355.5.
On 360 degree circle
A = 355.5 degree
B = 350 degrees #diff 5.5
C = 1 degree #diff 6.5
D = 320 degrees #diff 35.5
E = 348 degrees #diff 7.5
If the difference is less than 10 then it the correct answer. i.e. B, C, E. How to formulate this?
So I think you are asking how do you calculate the degrees of difference between two angles.
Usually we can simply subtract them. If $A= 45^\circ$ and $B=92^\circ$ then the angular difference between them is $|92^\circ - 45^\circ| = 47^{\circ}$. But a problem might arise when one angle is close to the "start" and the other at the end and you need to "go through" the "start" of the circle.
For example if $A = 349$ and $B = 20$ then the difference shouldn't be $|349 - 20| = 329$. That's going the "long" way around the circle. The answer should be: if you increase from $349$ an extra $11^\circ$ you come to $360^\circ = 0^\circ$ and return to the origin. Then you go another $20$ degrees and get to $20^\circ$. So the difference is $11 + 20 = 31$.
So is your question how do we deal with those "go around the origin" cases?
One thing to note: If going from point $A$ to $B$ takes $M^\circ$ in one direction, it will take $360^\circ - M^\circ$ in the other direction. And if one of those is more than $180^\circ$ the other will be less than $180^\circ$. (And if one is exactly $180^\circ$ the other will be too.)
And that's the key.
If we redid our $A = 349$ and $B=20$ and tried to find the difference by $|349-20|= 329$ we can see that $329 > 180$ so we took the long way round. SO the other way would be $360 - 329= 31^\circ$. And that is the short way round.
So the short way round is $\min (|A-B|, 360-|A-B|)$.
Steps:
1) Take $|A-B|$.
2) If $|A-B| \le 180$ you are done. That's your answer. other wise
3) If $|A-B| > 180$, take $360-|A-B|$. You are done.