X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9a83f860948059b0273b5cc6d9e43fadad3ebfca..b7d74e9ca32b2ffd17bd0f98fde97361b6d5ec0f:/src/common/longlong.cpp diff --git a/src/common/longlong.cpp b/src/common/longlong.cpp index 27e771096d..1ceefe0123 100644 --- a/src/common/longlong.cpp +++ b/src/common/longlong.cpp @@ -133,6 +133,22 @@ wxULongLongNative& wxULongLongNative::operator=(const class wxULongLongWx &ll) } #endif +#ifdef __VISUALC6__ +double wxULongLongNative::ToDouble() const +{ + // Work around the problem of casting unsigned __int64 to double in VC6 + // (which for unknown reasons only manifests itself in DLL builds, i.e. + // when using /MD). + static const __int64 int64_t_max = 9223372036854775807i64; + if ( m_ll <= int64_t_max ) + return wx_truncate_cast(double, (wxLongLong_t)m_ll); + + double d = wx_truncate_cast(double, int64_t_max); + d += (__int64)(m_ll - int64_t_max - 1); // The cast is safe because of -1 + return d + 1; +} +#endif // __VISUALC6__ + #endif // wxUSE_LONGLONG_NATIVE // ============================================================================