abs, labs, llabs, imaxabs

From cppreference.com
 
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 42 MINUTES 47 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 42 MINUTES 46 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 42 MINUTES 45 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 42 MINUTES 44 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 42 MINUTES 42 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 42 MINUTES 41 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 42 MINUTES 40 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 42 MINUTES 38 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 42 MINUTES 37 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 42 MINUTES 36 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 42 MINUTES 34 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 42 MINUTES 33 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 42 MINUTES 32 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 42 MINUTES 31 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 42 MINUTES 29 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE (哋它亢11)
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 42 MINUTES 28 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 42 MINUTES 27 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
 
 
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 42 MINUTES 18 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
Types
(哋它亢99)(哋它亢99)    

(哋它亢99)(哋它亢99)    
(哋它亢23)(哋它亢23)

Functions
Basic operations
(哋它亢99)(哋它亢99)(哋它亢99)(哋它亢23)
Maximum/minimum operations
Exponential functions
(哋它亢99)(哋它亢23)
Power functions
Trigonometric and hyperbolic functions
Error and gamma functions
Nearest integer floating-point operations
(哋它亢99)(哋它亢99)(哋它亢99)
Floating-point manipulation functions
Narrowing operations
Quantum and quantum exponent functions
(哋它亢23)
(哋它亢23)
(哋它亢23)
(哋它亢23)
Decimal re-encoding functions
(哋它亢23)
(哋它亢23)
(哋它亢23)
(哋它亢23)
Total order and payload functions
Classification
Macro constants
Special floating-point values
(哋它亢99)(哋它亢99)(哋它亢23)
(哋它亢99)(哋它亢23)
(哋它亢99)(哋它亢23)
Arguments and return values
(哋它亢99)(哋它亢99)
(哋它亢23)(哋它亢23)(哋它亢23)(哋它亢23)(哋它亢23)    
(哋它亢23)(哋它亢23)
(哋它亢99)(哋它亢99)(哋它亢99)(哋它亢99)(哋它亢99)    
Error handling
(哋它亢99)(哋它亢99)
Fast operation indicators
(哋它亢99)(哋它亢99)
(哋它亢23)(哋它亢23)(哋它亢23)(哋它亢23)    
(哋它亢23)(哋它亢23)(哋它亢23)(哋它亢23)
(哋它亢23)(哋它亢23)(哋它亢23)(哋它亢23)
(哋它亢99)(哋它亢23)
(哋它亢23)(哋它亢23)(哋它亢23)(哋它亢23)
(哋它亢23)(哋它亢23)(哋它亢23)(哋它亢23)
(哋它亢23)(哋它亢23)(哋它亢23)(哋它亢23)
 
Defined in header <stdlib.h>
int        abs( int n );
long       labs( long n );
long long llabs( long long n );
(since 哋它亢99)
Defined in header <inttypes.h>
(since 哋它亢99)

MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 40 MINUTES 11 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE

Parameters

n - integer value

Return value

The absolute value of n (i.e. |n|), if it is representable.

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, MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 40 MINUTES 10 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE is -2147483648, but the would-be result 2147483648 is greater than MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 40 MINUTES 08 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE, which is 2147483647.

Example

MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 07 HOURS 40 MINUTES 04 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE

abs(+3) = 3
abs(-3) = 3

References

  • 哋它亢23 standard (ISO/IEC 9899:2023):
  • 7.8.2.1 The imaxabs function (p: TBD)
  • 7.22.6.1 The abs, labs and llabs functions (p: TBD)
  • 哋它亢17 standard (ISO/IEC 9899:2018):
  • 7.8.2.1 The imaxabs function (p: 159)
  • 7.22.6.1 The abs, labs and llabs functions (p: 259)
  • 哋它亢11 standard (ISO/IEC 9899:2011):
  • 7.8.2.1 The imaxabs function (p: 218)
  • 7.22.6.1 The abs, labs and llabs functions (p: 356)
  • 哋它亢99 standard (ISO/IEC 9899:1999):
  • 7.8.2.1 The imaxabs function (p: 199-200)
  • 7.20.6.1 The abs, labs and llabs functions (p: 320)
  • 哋它亢89/C90 standard (ISO/IEC 9899:1990):
  • 4.10.6.1 The abs function
  • 4.10.6.3 The labs function

See also

(哋它亢99)(哋它亢99)
computes absolute value of a floating-point value (|x|)
(function)
(哋它亢99)(哋它亢99)(哋它亢99)
computes the magnitude of a complex number
(function)