X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=functions%2Fmath%2Fabs.c;h=0dae242f025b8e99f597e9953e33041e1d172131;hp=1cd660dce46225a67b2195d38980a116c2d1435b;hb=1d9d92ba957a0b8307c9a65c35867fde68e6533b;hpb=34893ecc2200dc7017c36a54cb6c5f4c2378b5ec diff --git a/functions/math/abs.c b/functions/math/abs.c index 1cd660d..0dae242 100644 --- a/functions/math/abs.c +++ b/functions/math/abs.c @@ -1,26 +1,28 @@ -// ---------------------------------------------------------------------------- -// $Id$ -// ---------------------------------------------------------------------------- -// Public Domain C Library - http://pdclib.sourceforge.net -// This code is Public Domain. Use, modify, and redistribute at will. -// ---------------------------------------------------------------------------- +/* ---------------------------------------------------------------------------- + * $Id$ + * ---------------------------------------------------------------------------- + * Public Domain C Library - http://pdclib.sourceforge.net + * This code is Public Domain. Use, modify, and redistribute at will. + * --------------------------------------------------------------------------*/ -// ---------------------------------------------------------------------------- -// C++ - -double abs( double x ) { /* TODO */ }; -float abs( float x ) { /* TODO */ }; -long double abs( long double x ) { /* TODO */ }; -float fabs( float x ) { /* TODO */ }; -long double fabs( long double x ) { /* TODO */ }; +double fabs( double x ) { /* TODO */ }; -long abs( long i ) { /* TODO */ }; -long long abs( long long i ) { /* TODO */ }; +/* Therx code +{ + return ( x < 0 ) ? -x : x; +} +*/ -// ---------------------------------------------------------------------------- -// Standard C +/* PDPC code - unreviewed +{ + if (x < 0.0) + { + x = -x; + } + return (x); +} +*/ -double fabs( double x ) { /* TODO */ }; float fabsf( float x ) { /* TODO */ }; long double fabsl( long double x ) { /* TODO */ };