[Previous] [Contents] [Next]

labs()

Calculate the absolute value of a long integer

Synopsis:

#include <stdlib.h>

long labs( long j );

Library:

libc

Description:

The labs() function returns the absolute value of its long-integer argument j.

Returns:

The absolute value of j.

Examples:

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

int main( void )
{
    long x, y;

    x = -50000;
    y = labs( x );
    printf( "labs( %d ) = %d\n", x, y );
    return EXIT_SUCCESS;
}

produces the output:

labs( -50000 ) = 50000

Classification:

ANSI

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

See also:

abs(), fabs()


[Previous] [Contents] [Next]