diff options
author | Steve Kargl <kargl@FreeBSD.org> | 2015-02-07 00:38:18 +0000 |
---|---|---|
committer | Steve Kargl <kargl@FreeBSD.org> | 2015-02-07 00:38:18 +0000 |
commit | dc98c004640831c88d7d4c25966674ba226ccbb2 (patch) | |
tree | d96148ac5a41c96a2235ca90c90a70680f720793 /lib/msun | |
parent | 4ef0c81f7dc4cf6bc47608941b3a3b8e5440dce9 (diff) | |
download | src-dc98c004640831c88d7d4c25966674ba226ccbb2.tar.gz src-dc98c004640831c88d7d4c25966674ba226ccbb2.zip |
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
Notes
Notes:
svn path=/head/; revision=278339
Diffstat (limited to 'lib/msun')
-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 dcf2c789ec32..5e4e42e9dcf0 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)); } |