Compute the absolute value of an integer.
Compatibility:This function is compatible with the following targets:
|
|
#include <stdlib.h>
int abs(int i);Parameters:
Parameters for this facility are:
#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