[Libreoffice-commits] core.git: tools/source

David Tardon dtardon at redhat.com
Fri Oct 17 12:46:51 PDT 2014


 tools/source/generic/bigint.cxx |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

New commits:
commit bac6e18d687266d9b9025ac9b80e6503b89a9d51
Author: David Tardon <dtardon at redhat.com>
Date:   Fri Oct 17 21:42:35 2014 +0200

    fix long long -> BigInt for LONG_MAX value
    
    Change-Id: I1cf551299bae925b5a5cf0a488b6cc3497d010bf

diff --git a/tools/source/generic/bigint.cxx b/tools/source/generic/bigint.cxx
index 43c0f68..a6acdc8 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
 


More information about the Libreoffice-commits mailing list