[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


abs

Compute the absolute value of an integer.

Compatibility:

This function is compatible with the following targets:

ANSI

BeOS

EMB/RTOS

Mac OS

Palm OS

Win32


Prototype:
#include <stdlib.h>
int abs(int i);
Parameters:

Parameters for this facility are:

i  
int  
The value being computed  

Return:

abs() returns the absolute value of its argument. Note that the two's complement representation of the smallest negative number has no matching absolute integer representation.

See Also:

"fabs"

"labs"

Example of abs() usage.:
#include <stdlib.h>
#include <stdio.h>

int main(void)
{
	int i = -20;
	long int j = -48323;
  long long k = -9223372036854773307;

	
	printf("Absolute value of %d is %d.\n", i, abs(i));
	printf("Absolute value of %ld is %ld.\n", j, labs(j));
	printf("Absolute value of %lld is %lld.\n", k, llabs(k));

	return 0;
}

Output:
Absolute value of -20 is 20.
Absolute value of -48323 is 48323.
Absolute value of -9223372036854773307 is 9223372036854773307.


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 16, 2000