X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdlib%2Fllabs.c;fp=functions%2Fstdlib%2Fllabs.c;h=ab9aca10baeed9d245afe1903eb26b3ad655565d;hb=bf2467f8b7d21570e11985421f2359a24a739134;hp=0000000000000000000000000000000000000000;hpb=ebf0a81fd96458d141a50dddc1c56145b38eef1f;p=pdclib diff --git a/functions/stdlib/llabs.c b/functions/stdlib/llabs.c new file mode 100644 index 0000000..ab9aca1 --- /dev/null +++ b/functions/stdlib/llabs.c @@ -0,0 +1,35 @@ +/* $Id$ */ + +/* Release $Name$ */ + +/* llabs( long int ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include + +#ifndef REGTEST + +long long int llabs( long long int j ) +{ + return ( j >= 0 ) ? j : -j; +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> +#include + +int main() +{ + BEGIN_TESTS; + TESTCASE( llabs( 0 ) == 0 ); + TESTCASE( llabs( LLONG_MAX ) == LLONG_MAX ); + TESTCASE( llabs( LLONG_MIN + 1 ) == -( LLONG_MIN + 1 ) ); + return TEST_RESULTS; +} + +#endif