I need the function dist (a, b) // 0 โค a, b <12, which returns the shortest (absolute ie + ve) distance alammetry of the alam using modulo 12.
So for example
dist( 1, 2 ) = dist( 2, 1 ) = dist( 11, 0 ) = dist( 0, 11 ) = dist( 0.5, 11.5 ) = 1
EDIT: while this can be easily done with a little hack, I feel like there should be some kind of intuitive solution, it is possible to use fmod and modulo 6
source share