diff --git a/include/wx/longlong.h b/include/wx/longlong.h index d2f1ed26de..5ff8a9b01c 100644 --- a/include/wx/longlong.h +++ b/include/wx/longlong.h @@ -27,8 +27,10 @@ // define this to compile wxLongLongWx in "test" mode: the results of all // calculations will be compared with the real results taken from -// wxLongLongNative -#define wxLONGLONG_TEST_MODE +// wxLongLongNative -- this is extremely useful to find the bugs in +// wxLongLongWx class! + +//#define wxLONGLONG_TEST_MODE #ifdef wxLONGLONG_TEST_MODE #define wxUSE_LONGLONG_WX 1 diff --git a/src/common/longlong.cpp b/src/common/longlong.cpp index 6a0cc8e315..5fd1016b5f 100644 --- a/src/common/longlong.cpp +++ b/src/common/longlong.cpp @@ -91,34 +91,26 @@ wxLongLongWx& wxLongLongWx::Assign(double d) { bool positive = d >= 0; d = fabs(d); - if ( d <= LONG_MAX ) + if ( d <= ULONG_MAX ) { m_hi = 0; m_lo = (long)d; } else { -#if 0 - m_lo = (long)d; - d -= m_lo; - d /= 0x1000; - d /= 0x1000; - d /= 0x100; - m_hi = (long)d; -#else - wxFAIL_MSG(_T("TODO")); -#endif + m_hi = (unsigned long)(d / (1.0 + (double)ULONG_MAX)); + m_lo = (unsigned long)(d - ((double)m_hi * (1.0 + (double)ULONG_MAX))); } - if ( !positive ) - m_hi = -m_hi; - #ifdef wxLONGLONG_TEST_MODE m_ll = (wxLongLong_t)d; Check(); #endif // wxLONGLONG_TEST_MODE + if ( !positive ) + Negate(); + return *this; }