diff --git a/src/common/longlong.cpp b/src/common/longlong.cpp index 62afbf79a4..aa40465563 100644 --- a/src/common/longlong.cpp +++ b/src/common/longlong.cpp @@ -1105,7 +1105,10 @@ void *wxULongLongWx::asArray(void) const \ while ( ll != 0 ) \ { \ - result.Prepend((wxChar)(_T('0') + (ll % 10).ToLong())); \ + long digit = (ll % 10).ToLong(); \ + if ( neg ) \ + digit = -digit; \ + result.Prepend((wxChar)(_T('0') + digit)); \ ll /= 10; \ } \ \ diff --git a/tests/longlong/longlongtest.cpp b/tests/longlong/longlongtest.cpp index 5b7920bf87..043a259cef 100644 --- a/tests/longlong/longlongtest.cpp +++ b/tests/longlong/longlongtest.cpp @@ -303,6 +303,9 @@ void LongLongTestCase::ToString() a.Negate(); CPPUNIT_ASSERT( a.ToString() == _T("-1311768467139281697") ); + wxLongLong llMin(LONG_MIN, 0); + CPPUNIT_ASSERT( a.ToString() == _T("-9223372036854775808") ); + #if wxUSE_LONGLONG_WX wxLongLongWx a1(a.GetHi(), a.GetLo()); CPPUNIT_ASSERT( a1.ToString() == _T("-1311768467139281697") );