X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fmath%2Ffloor.c;h=ea890bea1ec08bb9b1e21f39eb58c20e9f9de775;hb=f55adb4aa65c00fb155de6bad626acb9ff6365b3;hp=30cc4630d39b0665d75d0a5545af276f6e4ec132;hpb=34893ecc2200dc7017c36a54cb6c5f4c2378b5ec;p=pdclib diff --git a/functions/math/floor.c b/functions/math/floor.c index 30cc463..ea890be 100644 --- a/functions/math/floor.c +++ b/functions/math/floor.c @@ -5,15 +5,33 @@ // 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 */ };