summaryrefslogtreecommitdiff
path: root/src/inttypes/imaxabs.c
blob: be184ebff7f8c8bc65cc8f470e0f41819bb66c00 (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
#include "stddef.h"
#include <inttypes.h>

/** absolute value **/

intmax_t imaxabs(intmax_t j)
{
	if (j == INTMAX_MIN) {
		/* undefined behavior */
		return INTMAX_MIN;
	}
	
	return j < 0 ? -j : j;
}

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

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