1.8 KiB
1.8 KiB
[c.math.abs]
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 and declare 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 X for which is_unsigned_v is true and if X cannot be converted to int by integral promotion, the program is ill-formed.
[Note 2:
Allowing arguments that can be promoted to int provides 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:2024, 7.12.7.2, 7.22.6.1