and
div
eof
not
or
xor
Expand Minimize

imaxabs

Visual Studio 2013

Calculates the absolute value of an integer of any size.

intmax_t imaxabs(
   intmax_t n 
);

n

Integer value.

The imaxabs function returns the absolute value of the argument. There is no error return.

Note Note

Because the range of negative integers that can be represented by using intmax_t is larger than the range of positive integers that can be represented, it's possible to supply an argument to imaxabs that can’t be converted. If the absolute value of the argument cannot be represented by the return type, the behavior of imaxabs is undefined.

Routine

Required header

imaxabs

<inttypes.h>

For additional compatibility information, see Compatibility.

Libraries

All versions of the C run-time libraries.

// crt_imaxabs.c
// Build using: cl /W3 /Tc crt_imaxabs.c
// This example calls imaxabs to compute an
// absolute value, then displays the results.

#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>

int main(int argc, char *argv[])
{
   intmax_t x = LLONG_MIN + 2;

   printf("The absolute value of %lld is %lld\n", x, imaxabs(x));
}
The absolute value of -9223372036854775806 is 9223372036854775806
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft