From 617ec45690c340d059726a09ccfe4bab9a42d82e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 8 Jan 2000 14:26:40 +0000 Subject: [PATCH] wxLongLongWx::Assign(double) works - thanks Guillermo git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5299 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/longlong.h | 6 ++++-- src/common/longlong.cpp | 20 ++++++-------------- 2 files changed, 10 insertions(+), 16 deletions(-) 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; }