summaryrefslogtreecommitdiff
path: root/src/inttypes/imaxabs.c
blob: 04cb0440666fecb9d89c4589b6e2f6c100f53c74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <inttypes.h>
#include "_safety.h"

/** absolute value **/

intmax_t imaxabs(intmax_t j)
{
	SIGNAL_SAFE(0);

	if (j == INTMAX_MIN) {
		UNDEFINED("In call to imaxabs(): The absoluate value of INTMAX_MIN is not representable as an intmax_t");
		return INTMAX_MIN;
	}
	
	return j < 0 ? -j : j;
}

CHECK_1(intmax_t, 0, imaxabs, intmax_t)

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

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