blob: 7d6be9232c41d8b5a5bfe4e5b08f44fd962e60fc (
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 "stddef.h"
#include <inttypes.h>
intmax_t imaxabs(intmax_t j)
{
/* returns the absolute value of j */
/* if imaxabs(j) can't be representeted (i.e. imaxabs(INTMAX_MIN), behavior is undefined */
/*
if (j == INTMAX_MIN) {
__ungol_libc_undefined("Cannot represent absolute value of %" PRIxMAX "\n", j);
}
*/
if (j == INTMAX_MIN) {
/* undefined behavior */
return INTMAX_MIN;
}
if (j < 0) {
return -j;
}
return j;
}
/*
STDC(199901)
*/
|