[Previous] [Contents] [Next]

abs()

Return the absolute value of an integer

Synopsis:

#include <stdlib.h>

int abs( int j );

Library:

libc

Description:

The abs() function returns the absolute value of the integer argument j. If the result can't be represented as an int, a warning occurs.

Returns:

The absolute value of its argument.

Examples:

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

int main( void )
{
    printf( "%d %d %d\n", abs (-5), abs (0), abs (5));
    return EXIT_SUCCESS;
}

produces the following output:

5 0 5

Classification:

ANSI

Safety:
Cancellation point No
Interrupt handler Yes
Signal handler Yes
Thread Yes

See also:

fabs(), labs()


[Previous] [Contents] [Next]