Truncate the exponent 'n' of type long to a domain contained

within [INT_MIN, INT_MAX] where the magnitude of the lower
and upper bounds are sufficiently large to span the range of
scalbn[fl].

While here, remove the GNU style bug in the function declarations.

Reviewed by:	bde, pfg
This commit is contained in:
Steve Kargl 2015-02-07 00:38:18 +00:00
parent 4ef0c81f7d
commit dc98c00464

View File

@ -27,38 +27,28 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <limits.h>
#include <math.h>
double
scalbln (double x, long n)
{
int in;
#define NMAX 65536
#define NMIN -65536
in = (int)n;
if (in != n)
in = (n > 0) ? INT_MAX: INT_MIN;
return (scalbn(x, in));
double
scalbln(double x, long n)
{
return (scalbn(x, (n > NMAX) ? NMAX : (n < NMIN) ? NMIN : (int)n));
}
float
scalblnf (float x, long n)
scalblnf(float x, long n)
{
int in;
in = (int)n;
if (in != n)
in = (n > 0) ? INT_MAX: INT_MIN;
return (scalbnf(x, in));
return (scalbnf(x, (n > NMAX) ? NMAX : (n < NMIN) ? NMIN : (int)n));
}
long double
scalblnl (long double x, long n)
scalblnl(long double x, long n)
{
int in;
in = (int)n;
if (in != n)
in = (n > 0) ? INT_MAX: INT_MIN;
return (scalbnl(x, in));
return (scalbnl(x, (n > NMAX) ? NMAX : (n < NMIN) ? NMIN : (int)n));
}