diff options
author | David Tardon <dtardon@redhat.com> | 2014-10-17 21:42:35 +0200 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2014-10-17 21:45:21 +0200 |
commit | bac6e18d687266d9b9025ac9b80e6503b89a9d51 (patch) | |
tree | ff83c2217c145c1f89abd8a8c1fe3d1c637d40f7 /tools | |
parent | 68c9515daf6648646788b70825ffa261e1fadf60 (diff) |
fix long long -> BigInt for LONG_MAX value
Change-Id: I1cf551299bae925b5a5cf0a488b6cc3497d010bf
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/generic/bigint.cxx | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/tools/source/generic/bigint.cxx b/tools/source/generic/bigint.cxx index 43c0f68c3425..a6acdc8bb98c 100644 --- a/tools/source/generic/bigint.cxx +++ b/tools/source/generic/bigint.cxx @@ -586,10 +586,15 @@ BigInt::BigInt( long long nValue ) bIsNeg = nValue < 0; nLen = 0; - unsigned long long nUValue = static_cast<unsigned long long>(bIsNeg ? -nValue : nValue); - if (nUValue >= std::numeric_limits<long>::max()) + if ((nValue >= std::numeric_limits<long>::min()) && (nValue <= std::numeric_limits<long>::max())) + { + bIsBig = false; + nVal = static_cast<long>(nValue); + } + else { bIsBig = true; + const unsigned long long nUValue = static_cast<unsigned long long>(bIsNeg ? -nValue : nValue); for (int i = 0; (i != sizeof(unsigned long long) / 2) && (nUValue != 0); ++i) { nNum[i] = static_cast<sal_uInt16>(nUValue & 0xffffUL); @@ -597,11 +602,6 @@ BigInt::BigInt( long long nValue ) ++nLen; } } - else - { - bIsBig = false; - nVal = static_cast<long>(nValue); - } } #endif |