diff options
author | David Tardon <dtardon@redhat.com> | 2014-10-17 13:08:32 +0200 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2014-10-17 13:17:21 +0200 |
commit | 968cadb82542b23271b8c472a2e6ec9248343925 (patch) | |
tree | a86a6c4fa87f43c3b053e38c0294ae5cbb234719 /tools/source/generic | |
parent | 08280034197b577abf994cc05322c010fd1f9895 (diff) |
allow construction of BigInt from sal_Int64 on 32 bit
Change-Id: Ib68920fc9bd693d2f2679b4fc27d9956dc42fc86
Diffstat (limited to 'tools/source/generic')
-rw-r--r-- | tools/source/generic/bigint.cxx | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tools/source/generic/bigint.cxx b/tools/source/generic/bigint.cxx index 3311efd459b5..43c0f68c3425 100644 --- a/tools/source/generic/bigint.cxx +++ b/tools/source/generic/bigint.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <limits> #include <math.h> #include <rtl/ustrbuf.hxx> @@ -577,6 +578,33 @@ BigInt::BigInt( sal_uInt32 nValue ) } } +#if SAL_TYPES_SIZEOFLONG < SAL_TYPES_SIZEOFLONGLONG +BigInt::BigInt( long long nValue ) + : nVal(0) +{ + bIsSet = true; + bIsNeg = nValue < 0; + nLen = 0; + + unsigned long long nUValue = static_cast<unsigned long long>(bIsNeg ? -nValue : nValue); + if (nUValue >= std::numeric_limits<long>::max()) + { + bIsBig = true; + for (int i = 0; (i != sizeof(unsigned long long) / 2) && (nUValue != 0); ++i) + { + nNum[i] = static_cast<sal_uInt16>(nUValue & 0xffffUL); + nUValue = nUValue >> 16; + ++nLen; + } + } + else + { + bIsBig = false; + nVal = static_cast<long>(nValue); + } +} +#endif + BigInt::operator sal_uIntPtr() const { if ( !bIsBig ) |