[c.math.abs] (original) (raw)
29 Numerics library [numerics]
29.7 Mathematical functions for floating-point types [c.math]
29.7.2 Absolute values [c.math.abs]
[Note 1:
The headers anddeclare the functions described in this subclause.
— _end note_]
constexpr int abs(int j);constexpr long int abs(long int j);constexpr long long int abs(long long int j);
Effects: These functions have the semantics specified in the C standard library for the functions abs, labs, and llabs, respectively.
Remarks: If abs is called with an argument of type Xfor which is_unsigned_v<X> is true and if X cannot be converted to intby integral promotion, the program is ill-formed.
[Note 2:
Allowing arguments that can be promoted to intprovides compatibility with C.
— _end note_]
constexpr _floating-point-type_ abs(_floating-point-type_ x);
Returns: The absolute value of x.
See also: ISO/IEC 9899:2018, 7.12.7.2, 7.22.6.1