Do you mean -0x80000000 with seven 0s? The behavior of abs(-0x8000000) is certainly well defined (both uint32_t and int32_t contain ยฑ0x8000000 in their valid range if these types exist.
When a standard says that one behavior is undefined, it is undefined, even if some particular platform works in a certain way.
The C ++ abs function is taken from C, and the C standard says (ยง7.20.6.1 / 2):
The abs , labs and llabs functions compute the absolute value of the integer j . If the result cannot be presented, the behavior is undefined. 259)
259) The absolute value of the negative number itself cannot be represented in a double complement.
So the result of abs is undefined. Pratically returns 0x80000000 , but this is not the behavior defined by the standard.
source share