I don't understand the question. If the value provided is positive, the result will be positive. If the value provided is negative, the result will be the value multiplied by negative 1.
It is completely correct, but you are understanding it wrong.
If X is greater than or equal to 0, then it returns X. So, if X is 23 then it returns 23.
If X is less than 0 then it returns negative X. So, if X is -23 then it returns --23, which is 23 (two minuses make a plus).
Jek90:
Yep, according to this Absolute Value in Algebra the returning value must be always positive.(as is the distance from 0)
Unfortunately, that is the case in an ideal world. In the real world for integer data types on modern computers, the most negative number has no positive counterpart. This is due to the use of the two's complement arithmetic scheme for integers. On a system where ints are 16-bits (i.e. AVR based Arduinos), a signed integer can range from -32768 to +32767. If you do abs of -32768 or -(-32768), you get -32768 once again.
Now for floating point, the mantissa is typically represented in a sign magnitude method, where the sign bit is separate from the mantissa part, so you can do fabs/fabsf by just clearing the sign bit. However, the wrinkle in floating point is the existence of NaN (not a number). While if you look at the bits, there are theoretically negative and positive NaN's, a NaN of either sign will act the same, and always return false in any ordered comparison.
Furthermore, in terms of floating point and signs, is the concept of negative 0 (-0.0), which is possible by setting the sign bit to 1. However, normal floating point operations will treat -0.0 like 0.0, but there are a few places where negative zero crops up (the copysign and fma functions being the two big examples, but it also crops up in some other cases with high levels of optimization on certain machines).
In terms of integer representation, historically there were machines that used 2 other representations (sign-magnitude as used on Burroughs machines, and one's complement as used on Univac and CDC machines), but generally today modern machines use two's complement.