What is abs(x - y)

What is abs(x - y) , why do I even bother asking a question like that, much less answer it? Trust me, it's more interesting than it look...

@harold
Fun - and another blog to put in my feed!

One question: I can't think of an example where absdiff() will return a value larger than abs(). Or did I misunderstand that it's supposed to?

@jannem values that are very far apart, for example absdiff_s(0x80000000, 0x7fffffff) (distance from lowest signed int to highest signed int) is intended to be 0xFFFFFFFF (highest unsigned int of the same size) and not 1 (they are also a distance of 1 apart but that's a different notion of distance)
@jannem it may have been unclear that I intended for abs to interpret its input as signed regardless of where it came from ie abs(0xFFFFFFFF) = 1 because 0xFFFFFFFF is -1 as far as abs is concerned and there is no version of abs that interprets its input as unsigned integers and hence simply returns them unchanged (or perhaps in some programming language there might be but I think that'd be trolling)
@jannem or in terms of the number ring, I take abs to be the function that folds the half of the ring with the top bit set onto the other half, with the fold running through 0 and 0x80000000 (abs having 0x80000001 distinct outputs while we seem to be getting a perfectly-folded-in-half ring can be explained by the fact we end up with two numbers at the endpoints of the half-ring and there's the usual fence-post thing going on, we have exactly half of the fence and an extra post)
@harold i used this to represent a fixed point angle type in 16 bits. since the integer ring itself produces the modulo, angle arithmetic becomes short and elegant.