diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2011-10-12 21:51:36 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2011-10-12 21:51:36 +0000 |
commit | 7247a5f20e1997e38cdfe3558afe8f10d547f2eb (patch) | |
tree | 367b90616f993fb49ba90d29b321ea10be98e56c /lib/Support/APFloat.cpp | |
parent | 41242942fcbb2e6bc4e5bed3e8041f7b20ece8af (diff) |
Fix APFloat::getLargest so that it actually returns the correct value. Found by accident while reviewing a patch to nearby code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141816 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/APFloat.cpp')
-rw-r--r-- | lib/Support/APFloat.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/Support/APFloat.cpp b/lib/Support/APFloat.cpp index 5307829ed8..95df8617fb 100644 --- a/lib/Support/APFloat.cpp +++ b/lib/Support/APFloat.cpp @@ -3243,8 +3243,9 @@ APFloat APFloat::getLargest(const fltSemantics &Sem, bool Negative) { significand[i] = ~((integerPart) 0); // ...and then clear the top bits for internal consistency. - significand[N-1] &= - (((integerPart) 1) << ((Sem.precision % integerPartWidth) - 1)) - 1; + if (Sem.precision % integerPartWidth != 0) + significand[N-1] &= + (((integerPart) 1) << (Sem.precision % integerPartWidth)) - 1; return Val; } |