/* labs example */ #include <stdio.h> /* printf */ #include <stdlib.h> /* labs */ int main () { longint n,m; n=labs(65537L); m=labs(-100000L); printf ("n=%ld\n",n); printf ("m=%ld\n",m); return 0; }
Output:
n=65537 m=100000
Data races
Concurrently calling this function is safe, causing no data races.
Exceptions (C++)
No-throw guarantee: this function throws no exceptions.
If the result cannot be represented as a long int (such as labs(LONG_MIN) in an implementation with two's complement signed values), it causes undefined behavior.