Name

imaxabs

Synopsis

Gives the absolute value of a number of the longest available integer type

#include <inttypes.h>
intmax_timaxabs( intmax_t n )

The imaxabs() function is the same as either labs() or llabs(), depending on how many bits wide the system’s largest integer type is. Accordingly, the type intmax_t is the same as either long or long long.

Example

intmax_t quantity1 = 9182734;
intmax_t quantity2 = 1438756;

printf( "The difference between the two quantities is %ji.\n",imaxabs( quantity2 − quantity1 ));

Get C in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.