abs

From RAD Studio
Jump to: navigation, search

NOTE: This is a test page.

Go Up to math.h Index


Header file

stdlib.h, math.h

Prototype

int abs(int x);

Description

Returns the absolute value of an integer.

abs returns the absolute value of the integer argument x. If abs is called when stdlib.h has been included, it's treated as a macro that expands to inline code.

If you want to use the abs function instead of the macro, include

#undef abs

in your program, after the #include <stdlib.h>.

Return Value

The abs function returns an integer in the range of 0 to INT_MAX, with the exception that an argument with the value INT_MIN is returned as INT_MIN. The values for INT_MAX and INT_MIN are defined in header file limit.h.

Portability

POSIX ANSI C ANSI C++ NT+ Win32 Win64 OS X
abs + + + + +

Example

#include <stdio.h>
#include <math.h>

int main(void) {
	int number = -1234;
	printf("number: %d  absolute value: %d\n", number, abs(number));
	return 0;
}

See also