abs, labs, llabs, imaxabs
From cppreference.com
                    
                                        
                    
                    
                                                            
                    | Defined in header  <stdlib.h> | ||
| int        abs( int n ); | ||
| long       labs( long n ); | ||
| long long llabs( long long n ); | (since C99) | |
| Defined in header  <inttypes.h> | ||
| (since C99) | ||
Computes the absolute value of an integer number. The behavior is undefined if the result cannot be represented by the return type.
| Contents | 
[edit] Parameters
| n | - | integer value | 
[edit] Return value
The absolute value of n (i.e. |n|), if it is representable.
[edit] Notes
In 2's complement systems, the absolute value of the most-negative value is out of range, e.g. for 32-bit 2's complement type int, INT_MIN is -2147483648, but the would-be result 2147483648 is greater than INT_MAX, which is 2147483647.
[edit] Example
Run this code
Output:
abs(+3) = 3 abs(-3) = 3
[edit] See also
| (C99)(C99) | computes absolute value of a floating-point value (|x|) (function) | 
| (C99)(C99)(C99) | computes the magnitude of a complex number (function) | 
| C++ documentation for abs | |


