]> git.saurik.com Git - wxWidgets.git/commitdiff
wxLongLongWx::Assign(double) works - thanks Guillermo
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 8 Jan 2000 14:26:40 +0000 (14:26 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 8 Jan 2000 14:26:40 +0000 (14:26 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5299 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/longlong.h
src/common/longlong.cpp

index d2f1ed26dead8c329f503c346acaef1223345b15..5ff8a9b01c63fe5cd15e30b7c03cea688e0e6b15 100644 (file)
 
 // 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
index 6a0cc8e315a4c91eddd175f102fe634fb649dfa3..5fd1016b5f3b0801fe2330aeebb14c156c1f30a3 100644 (file)
@@ -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;
 }