summaryrefslogtreecommitdiff
path: root/src/stdlib/abs.c
blob: 5cf59b4e5a70b4c7051662e138b00d1a459c5c8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdlib.h>
#include <limits.h>

/** absolute value **/

int abs(int j)
{
	if (j == INT_MIN) {
		/* undefined behavior */
	}

	return j < 0 ? -j : j;
}

/***
computes the absolute value of ARGUMENT(j).
***/

/*
UNDEFINED(ABS(ARGUMENT(j)) cannot be represented)
RETURN_SUCCESS(ABS(j));
STDC(1)
*/