Files
2025-10-25 03:02:53 +03:00

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]

1

#

[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);

2

#

Effects: These functions have the semantics specified in the C standard library for the functions abs, labs, and llabs, respectively.

3

#

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);

4

#

Returns: The absolute value of x.

See also: ISO/IEC 9899:2024, 7.12.7.2, 7.22.6.1