From d870a03054ca05996857068c78f01b68fcf7b2a0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 13 Aug 2006 00:44:44 +0000 Subject: [PATCH] added wxULongLong::ToDouble() (patch 1531597) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40581 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/longlong.h | 6 ++++++ src/common/longlong.cpp | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/wx/longlong.h b/include/wx/longlong.h index 59dcd57c74..9b6553ea9a 100644 --- a/include/wx/longlong.h +++ b/include/wx/longlong.h @@ -410,6 +410,9 @@ public: return wx_truncate_cast(unsigned long, m_ll); } + // convert to double + double ToDouble() const { return wx_truncate_cast(double, m_ll); } + // operations // addition wxULongLongNative operator+(const wxULongLongNative& ll) const @@ -906,6 +909,9 @@ public: return (unsigned long)m_lo; } + // convert to double + double ToDouble() const; + // operations // addition wxULongLongWx operator+(const wxULongLongWx& ll) const; diff --git a/src/common/longlong.cpp b/src/common/longlong.cpp index 360d087b3e..772ecc0b9a 100644 --- a/src/common/longlong.cpp +++ b/src/common/longlong.cpp @@ -194,6 +194,19 @@ double wxLongLongWx::ToDouble() const return d; } +double wxULongLongWx::ToDouble() const +{ + unsigned double d = m_hi; + d *= 1.0 + (double)ULONG_MAX; + d += m_lo; + +#ifdef wxLONGLONG_TEST_MODE + wxASSERT( d == m_ll ); +#endif // wxLONGLONG_TEST_MODE + + return d; +} + wxLongLongWx wxLongLongWx::operator<<(int shift) const { wxLongLongWx ll(*this); -- 2.45.2