diff options
author | kargl <kargl@FreeBSD.org> | 2015-02-07 00:38:18 +0000 |
---|---|---|
committer | kargl <kargl@FreeBSD.org> | 2015-02-07 00:38:18 +0000 |
commit | 549ab093019cacb0fc6b9e00f13bd32dac63a3ff (patch) | |
tree | d96148ac5a41c96a2235ca90c90a70680f720793 /lib/msun/src | |
parent | 8b70db44d8034bf8e8758b308cf8b1de5e2d7183 (diff) | |
download | FreeBSD-src-549ab093019cacb0fc6b9e00f13bd32dac63a3ff.zip FreeBSD-src-549ab093019cacb0fc6b9e00f13bd32dac63a3ff.tar.gz |
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
Diffstat (limited to 'lib/msun/src')
-rw-r--r-- | lib/msun/src/s_scalbln.c | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/lib/msun/src/s_scalbln.c b/lib/msun/src/s_scalbln.c index dcf2c78..5e4e42e 100644 --- a/lib/msun/src/s_scalbln.c +++ b/lib/msun/src/s_scalbln.c @@ -27,38 +27,28 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include <limits.h> #include <math.h> +#define NMAX 65536 +#define NMIN -65536 + double -scalbln (double x, long n) +scalbln(double x, long n) { - int in; - in = (int)n; - if (in != n) - in = (n > 0) ? INT_MAX: INT_MIN; - return (scalbn(x, in)); + 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)); } |