-wxString
-#if wxUSE_LONGLONG_NATIVE
-wxLongLongNative::ToString() const
-#else
-wxLongLongWx::ToString() const
-#endif
-{
- // TODO: this is awfully inefficient, anything better?
- wxString result;
-
- wxLongLong ll = *this;
-
- bool neg;
- if ( ll < 0 )
- {
- ll.Negate();
- neg = true;
- }
- else
- {
- neg = false;
+#define LL_TO_STRING(name) \
+ wxString name::ToString() const \
+ { \
+ /* TODO: this is awfully inefficient, anything better? */ \
+ wxString result; \
+ \
+ name ll = *this; \
+ \
+ bool neg = ll < 0; \
+ if ( neg ) \
+ { \
+ while ( ll != 0 ) \
+ { \
+ long digit = (ll % 10).ToLong(); \
+ result.Prepend((wxChar)(_T('0') - digit)); \
+ ll /= 10; \
+ } \
+ } \
+ else \
+ { \
+ while ( ll != 0 ) \
+ { \
+ long digit = (ll % 10).ToLong(); \
+ result.Prepend((wxChar)(_T('0') + digit)); \
+ ll /= 10; \
+ } \
+ } \
+ \
+ if ( result.empty() ) \
+ result = _T('0'); \
+ else if ( neg ) \
+ result.Prepend(_T('-')); \
+ \
+ return result; \