I have some code where I need to extract the sign of an integer and its absolute value (so for -12, I need the sign -1 and the number 12.)
There are many ways to do this, but which is best. In my application I don't need to worry about 0 which has a sign of +1 (usually!).
I first thought of
SIGN_N = SIGN(1,N)
ABS_N = ABS(N)
Then I realised that the following was also possible.
SIGN_N = SIGN(1,N)
ABS_N = SIGN(N,1)
Which is clearer? Is ABS() really just a special kind of SIGN(). How is it implemented in the compiler?
[/code]