X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=blobdiff_plain;f=libgfortran%2Fintrinsics%2Fc99_functions.c;h=a95f09ac01d79e7417a7064bce99d2b7e213ac62;hp=8a9c2f1d525fb2136fcb4ce37f4f0c880241d8ee;hb=bf09288ee7b5f264f28081a84fde4c6aa1ac5c82;hpb=d91f7526fb89f7d993f570efe6ca75ab6f856370 diff --git a/libgfortran/intrinsics/c99_functions.c b/libgfortran/intrinsics/c99_functions.c index 8a9c2f1d525..a95f09ac01d 100644 --- a/libgfortran/intrinsics/c99_functions.c +++ b/libgfortran/intrinsics/c99_functions.c @@ -559,6 +559,37 @@ powf (float x, float y) #endif +#ifndef HAVE_ROUND +#define HAVE_ROUND 1 +/* Round to nearest integral value. If the argument is halfway between two + integral values then round away from zero. */ +double round (double x); + +double +round (double x) +{ + double t; + if (!isfinite (x)) + return (x); + + if (x >= 0.0) + { + t = floor (x); + if (t - x <= -0.5) + t += 1.0; + return (t); + } + else + { + t = floor (-x); + if (t + x <= -0.5) + t += 1.0; + return (-t); + } +} +#endif + + /* Algorithm by Steven G. Kargl. */ #if !defined(HAVE_ROUNDL) @@ -600,7 +631,7 @@ roundl (long double x) if (x > DBL_MAX || x < -DBL_MAX) { #ifdef HAVE_NEXTAFTERL - static long double prechalf = nexafterl (0.5L, LDBL_MAX); + long double prechalf = nextafterl (0.5L, LDBL_MAX); #else static long double prechalf = 0.5L; #endif @@ -614,36 +645,6 @@ roundl (long double x) #endif #endif -#ifndef HAVE_ROUND -#define HAVE_ROUND 1 -/* Round to nearest integral value. If the argument is halfway between two - integral values then round away from zero. */ -double round (double x); - -double -round (double x) -{ - double t; - if (!isfinite (x)) - return (x); - - if (x >= 0.0) - { - t = floor (x); - if (t - x <= -0.5) - t += 1.0; - return (t); - } - else - { - t = floor (-x); - if (t + x <= -0.5) - t += 1.0; - return (-t); - } -} -#endif - #ifndef HAVE_ROUNDF #define HAVE_ROUNDF 1 /* Round to nearest integral value. If the argument is halfway between two