llabs

Calculates the absolute value of a long long integer.

Include

<stdlib.h>

Prototype

long long llabs(long long i);

Argument

i
long integer value

Return Value

Returns the absolute value of i.

Remarks

A negative number is returned as positive; a positive number is unchanged.

Example

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

int main(void)
{
  long long i;

  i = 123456;
  printf("The absolute value of %7lld is %6lld\n", i, llabs(i));

  i = -246834;
  printf("The absolute value of %7lld is %6lld\n", i, llabs(i));

  i = 0;
  printf("The absolute value of %7lld is %6lld\n", i, llabs(i));
}

Example Output

The absolute value of  123456 is 123456
The absolute value of -246834 is 246834
The absolute value of       0 is      0