X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=functions%2Fmath%2Ffloor.c;h=7d62107e17f7bac1332d38c7a7ae197aa00c16b7;hp=30cc4630d39b0665d75d0a5545af276f6e4ec132;hb=1d9d92ba957a0b8307c9a65c35867fde68e6533b;hpb=34893ecc2200dc7017c36a54cb6c5f4c2378b5ec diff --git a/functions/math/floor.c b/functions/math/floor.c index 30cc463..7d62107 100644 --- a/functions/math/floor.c +++ b/functions/math/floor.c @@ -1,19 +1,37 @@ -// ---------------------------------------------------------------------------- -// $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 floor( double x ) { /* TODO */ }; -float floor( float x ) { /* TODO */ }; -long double floor( long double x ) { /* TODO */ }; +/* Therx code +{ + return ( x > 0 ) ? (int) x : (int) ( x - 0.9999999999999999 ); +} +*/ -// ---------------------------------------------------------------------------- -// Standard C +/* PDPC code - unreviewed +{ + int y; + + if (x < 0.0) + { + y = (int)fabs(x); + if ((double)y != x) + { + y--; + } + } + else + { + y = (int)x; + } + return ((double)x); +} +*/ -double floor( double x ) { /* TODO */ }; float floorf( float x ) { /* TODO */ }; long double floorl( long double x ) { /* TODO */ };