CKTIS / C
llabs — C23 arithmetic utility function
`llabs(j)` from `<stdlib.h>` returns the absolute value of a `long long int` argument with the same result type. It neither parses text nor sets `errno`.
Version: C23
Syntax
long long int llabs(long long int j);llabs(j) from <stdlib.h> returns the absolute value of a long long int argument with the same result type. It neither parses text nor sets errno.
The example calls llabs(-1234567890123LL) and prints 1234567890123. The LL suffix supplies the intended argument type and demonstrates a range wider than a typical long on some platforms.
For LLONG_MIN, the positive opposite is not representable as long long, so behavior is undefined; guard that case before calling. Use abs for int, labs for long, and fabs for floating-point values.
Examples
#include <stdio.h>
#include <stdlib.h>
int main(void){printf("%lld\n",llabs(-1234567890123LL));return 0;}
Result
1234567890123
The example calls `llabs(-1234567890123LL)` and prints `1234567890123`. The `LL` suffix supplies the intended argument type and demonstrates a range wider than a typical `long` on some platforms.