diff options
author | pfg <pfg@FreeBSD.org> | 2015-02-03 14:17:29 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2015-02-03 14:17:29 +0000 |
commit | 21bdbd8a2dead801fd744af6140f5b5272e1c674 (patch) | |
tree | e5345e1e325e85db41068f0d77018aba8c98cd39 /lib/msun/src | |
parent | 360ba91b98c64fca635f13dcedabc954c5b06a9b (diff) | |
download | FreeBSD-src-21bdbd8a2dead801fd744af6140f5b5272e1c674.zip FreeBSD-src-21bdbd8a2dead801fd744af6140f5b5272e1c674.tar.gz |
Reduce confusion in scalbnl() family of functions.
The changes unrelated to the bug in r277948 made
the code very difficult to understand to both
coverity and regular humans so take a step back
to something that is much easier to understand
for both and follows better the original code.
CID: 1267992, 1267993, 1267994
Discussed with: kargl
Diffstat (limited to 'lib/msun/src')
-rw-r--r-- | lib/msun/src/s_scalbln.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/msun/src/s_scalbln.c b/lib/msun/src/s_scalbln.c index 2aa6900..7d134a6 100644 --- a/lib/msun/src/s_scalbln.c +++ b/lib/msun/src/s_scalbln.c @@ -35,7 +35,9 @@ scalbln (double x, long n) { int in; - in = (n > INT_MAX) ? INT_MAX : (n < INT_MIN) ? INT_MIN : n; + in = (int)n; + if (in != n) + in = (n > 0) ? INT_MAX: INT_MIN; return (scalbn(x, in)); } @@ -44,7 +46,9 @@ scalblnf (float x, long n) { int in; - in = (n > INT_MAX) ? INT_MAX : (n < INT_MIN) ? INT_MIN : n; + in = (int)n; + if (in != n) + in = (n > 0) ? INT_MAX: INT_MIN; return (scalbnf(x, in)); } @@ -53,6 +57,9 @@ scalblnl (long double x, long n) { int in; - in = (n > INT_MAX) ? INT_MAX : (n < INT_MIN) ? INT_MIN : n; + in = (int)n; + if (in != n) { + in = (n > 0) ? INT_MAX: INT_MIN; + } return (scalbnl(x, in)); } |