1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: declaration of wxLongLong class - best implementation of a 64
4 // bit integer for the current platform.
5 // Author: Jeffrey C. Ollie <jeff@ollie.clive.ia.us>, Vadim Zeitlin
9 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
13 #ifndef _WX_LONGLONG_H
14 #define _WX_LONGLONG_H
16 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
17 #pragma interface "longlong.h"
21 #include "wx/string.h"
23 #include <limits.h> // for LONG_MAX
25 // define this to compile wxLongLongWx in "test" mode: the results of all
26 // calculations will be compared with the real results taken from
27 // wxLongLongNative -- this is extremely useful to find the bugs in
28 // wxLongLongWx class!
30 // #define wxLONGLONG_TEST_MODE
32 #ifdef wxLONGLONG_TEST_MODE
33 #define wxUSE_LONGLONG_WX 1
34 #define wxUSE_LONGLONG_NATIVE 1
35 #endif // wxLONGLONG_TEST_MODE
37 // ----------------------------------------------------------------------------
38 // decide upon which class we will use
39 // ----------------------------------------------------------------------------
42 // both warning and pragma warning are not portable, but at least an
43 // unknown pragma should never be an error -- except that, actually, some
44 // broken compilers don't like it, so we have to disable it in this case
46 #if !(defined(__WATCOMC__) || defined(__VISAGECPP__))
47 #pragma warning "Your compiler does not appear to support 64 bit "\
48 "integers, using emulation class instead.\n" \
49 "Please report your compiler version to " \
50 "wx-dev@lists.wxwindows.org!"
53 #define wxUSE_LONGLONG_WX 1
56 // the user may predefine wxUSE_LONGLONG_NATIVE and/or wxUSE_LONGLONG_NATIVE
57 // to disable automatic testing (useful for the test program which defines
58 // both classes) but by default we only use one class
59 #if (defined(wxUSE_LONGLONG_WX) && wxUSE_LONGLONG_WX) || !defined(wxLongLong_t)
60 // don't use both classes unless wxUSE_LONGLONG_NATIVE was explicitly set:
61 // this is useful in test programs and only there
62 #ifndef wxUSE_LONGLONG_NATIVE
63 #define wxUSE_LONGLONG_NATIVE 0
66 class WXDLLIMPEXP_BASE wxLongLongWx
;
67 class WXDLLIMPEXP_BASE wxULongLongWx
;
68 #if defined(__VISUALC__) && !defined(__WIN32__)
69 #define wxLongLong wxLongLongWx
70 #define wxULongLong wxULongLongWx
72 typedef wxLongLongWx wxLongLong
;
73 typedef wxULongLongWx wxULongLong
;
77 // if nothing is defined, use native implementation by default, of course
78 #ifndef wxUSE_LONGLONG_NATIVE
79 #define wxUSE_LONGLONG_NATIVE 1
83 #ifndef wxUSE_LONGLONG_WX
84 #define wxUSE_LONGLONG_WX 0
85 class WXDLLIMPEXP_BASE wxLongLongNative
;
86 class WXDLLIMPEXP_BASE wxULongLongNative
;
87 typedef wxLongLongNative wxLongLong
;
88 typedef wxULongLongNative wxULongLong
;
91 // NB: if both wxUSE_LONGLONG_WX and NATIVE are defined, the user code should
92 // typedef wxLongLong as it wants, we don't do it
94 // ----------------------------------------------------------------------------
95 // choose the appropriate class
96 // ----------------------------------------------------------------------------
98 // we use iostream for wxLongLong output
99 #include "wx/iosfwrap.h"
101 #if wxUSE_LONGLONG_NATIVE
103 class WXDLLIMPEXP_BASE wxLongLongNative
107 // default ctor initializes to 0
108 wxLongLongNative() : m_ll(0) { }
110 wxLongLongNative(wxLongLong_t ll
) : m_ll(ll
) { }
112 wxLongLongNative(long hi
, unsigned long lo
) : m_ll(0)
114 // assign first to avoid precision loss!
115 m_ll
= ((wxLongLong_t
) hi
) << 32;
116 m_ll
|= (wxLongLong_t
) lo
;
119 // default copy ctor is ok
123 // assignment operators
124 // from native 64 bit integer
125 wxLongLongNative
& operator=(wxLongLong_t ll
)
126 { m_ll
= ll
; return *this; }
128 // from double: this one has an explicit name because otherwise we
129 // would have ambiguity with "ll = int" and also because we don't want
130 // to have implicit conversions between doubles and wxLongLongs
131 wxLongLongNative
& Assign(double d
)
132 { m_ll
= (wxLongLong_t
)d
; return *this; }
134 // assignment operators from wxLongLongNative is ok
139 { return (long)(m_ll
>> 32); }
141 unsigned long GetLo() const
142 { return (unsigned long)m_ll
; }
144 // get absolute value
145 wxLongLongNative
Abs() const { return wxLongLongNative(*this).Abs(); }
146 wxLongLongNative
& Abs() { if ( m_ll
< 0 ) m_ll
= -m_ll
; return *this; }
148 // convert to native long long
149 wxLongLong_t
GetValue() const { return m_ll
; }
151 // convert to long with range checking in the debug mode (only!)
154 wxASSERT_MSG( (m_ll
>= LONG_MIN
) && (m_ll
<= LONG_MAX
),
155 _T("wxLongLong to long conversion loss of precision") );
160 // don't provide implicit conversion to wxLongLong_t or we will have an
161 // ambiguity for all arithmetic operations
162 //operator wxLongLong_t() const { return m_ll; }
166 wxLongLongNative
operator+(const wxLongLongNative
& ll
) const
167 { return wxLongLongNative(m_ll
+ ll
.m_ll
); }
168 wxLongLongNative
& operator+=(const wxLongLongNative
& ll
)
169 { m_ll
+= ll
.m_ll
; return *this; }
171 wxLongLongNative
operator+(const wxLongLong_t ll
) const
172 { return wxLongLongNative(m_ll
+ ll
); }
173 wxLongLongNative
& operator+=(const wxLongLong_t ll
)
174 { m_ll
+= ll
; return *this; }
177 wxLongLongNative
& operator++()
178 { m_ll
++; return *this; }
181 wxLongLongNative
operator++(int)
182 { wxLongLongNative
value(*this); m_ll
++; return value
; }
185 wxLongLongNative
operator-() const
186 { return wxLongLongNative(-m_ll
); }
187 wxLongLongNative
& Negate() { m_ll
= -m_ll
; return *this; }
190 wxLongLongNative
operator-(const wxLongLongNative
& ll
) const
191 { return wxLongLongNative(m_ll
- ll
.m_ll
); }
192 wxLongLongNative
& operator-=(const wxLongLongNative
& ll
)
193 { m_ll
-= ll
.m_ll
; return *this; }
195 wxLongLongNative
operator-(const wxLongLong_t ll
) const
196 { return wxLongLongNative(m_ll
- ll
); }
197 wxLongLongNative
& operator-=(const wxLongLong_t ll
)
198 { m_ll
-= ll
; return *this; }
201 wxLongLongNative
& operator--()
202 { m_ll
--; return *this; }
205 wxLongLongNative
operator--(int)
206 { wxLongLongNative
value(*this); m_ll
--; return value
; }
210 wxLongLongNative
operator<<(int shift
) const
211 { return wxLongLongNative(m_ll
<< shift
);; }
212 wxLongLongNative
& operator<<=(int shift
)
213 { m_ll
<<= shift
; return *this; }
216 wxLongLongNative
operator>>(int shift
) const
217 { return wxLongLongNative(m_ll
>> shift
);; }
218 wxLongLongNative
& operator>>=(int shift
)
219 { m_ll
>>= shift
; return *this; }
222 wxLongLongNative
operator&(const wxLongLongNative
& ll
) const
223 { return wxLongLongNative(m_ll
& ll
.m_ll
); }
224 wxLongLongNative
& operator&=(const wxLongLongNative
& ll
)
225 { m_ll
&= ll
.m_ll
; return *this; }
227 wxLongLongNative
operator|(const wxLongLongNative
& ll
) const
228 { return wxLongLongNative(m_ll
| ll
.m_ll
); }
229 wxLongLongNative
& operator|=(const wxLongLongNative
& ll
)
230 { m_ll
|= ll
.m_ll
; return *this; }
232 wxLongLongNative
operator^(const wxLongLongNative
& ll
) const
233 { return wxLongLongNative(m_ll
^ ll
.m_ll
); }
234 wxLongLongNative
& operator^=(const wxLongLongNative
& ll
)
235 { m_ll
^= ll
.m_ll
; return *this; }
237 // multiplication/division
238 wxLongLongNative
operator*(const wxLongLongNative
& ll
) const
239 { return wxLongLongNative(m_ll
* ll
.m_ll
); }
240 wxLongLongNative
operator*(long l
) const
241 { return wxLongLongNative(m_ll
* l
); }
242 wxLongLongNative
& operator*=(const wxLongLongNative
& ll
)
243 { m_ll
*= ll
.m_ll
; return *this; }
244 wxLongLongNative
& operator*=(long l
)
245 { m_ll
*= l
; return *this; }
247 wxLongLongNative
operator/(const wxLongLongNative
& ll
) const
248 { return wxLongLongNative(m_ll
/ ll
.m_ll
); }
249 wxLongLongNative
operator/(long l
) const
250 { return wxLongLongNative(m_ll
/ l
); }
251 wxLongLongNative
& operator/=(const wxLongLongNative
& ll
)
252 { m_ll
/= ll
.m_ll
; return *this; }
253 wxLongLongNative
& operator/=(long l
)
254 { m_ll
/= l
; return *this; }
256 wxLongLongNative
operator%(const wxLongLongNative
& ll
) const
257 { return wxLongLongNative(m_ll
% ll
.m_ll
); }
258 wxLongLongNative
operator%(long l
) const
259 { return wxLongLongNative(m_ll
% l
); }
262 bool operator==(const wxLongLongNative
& ll
) const
263 { return m_ll
== ll
.m_ll
; }
264 bool operator==(long l
) const
265 { return m_ll
== l
; }
266 bool operator!=(const wxLongLongNative
& ll
) const
267 { return m_ll
!= ll
.m_ll
; }
268 bool operator!=(long l
) const
269 { return m_ll
!= l
; }
270 bool operator<(const wxLongLongNative
& ll
) const
271 { return m_ll
< ll
.m_ll
; }
272 bool operator<(long l
) const
274 bool operator>(const wxLongLongNative
& ll
) const
275 { return m_ll
> ll
.m_ll
; }
276 bool operator>(long l
) const
278 bool operator<=(const wxLongLongNative
& ll
) const
279 { return m_ll
<= ll
.m_ll
; }
280 bool operator<=(long l
) const
281 { return m_ll
<= l
; }
282 bool operator>=(const wxLongLongNative
& ll
) const
283 { return m_ll
>= ll
.m_ll
; }
284 bool operator>=(long l
) const
285 { return m_ll
>= l
; }
289 // return the string representation of this number
290 wxString
ToString() const;
292 // conversion to byte array: returns a pointer to static buffer!
293 void *asArray() const;
295 #if wxUSE_STD_IOSTREAM
297 friend wxSTD ostream
& operator<<(wxSTD ostream
&, const wxLongLongNative
&);
305 class WXDLLIMPEXP_BASE wxULongLongNative
309 // default ctor initializes to 0
310 wxULongLongNative() : m_ll(0) { }
312 wxULongLongNative(unsigned wxLongLong_t ll
) : m_ll(ll
) { }
314 wxULongLongNative(unsigned long hi
, unsigned long lo
) : m_ll(0)
316 // assign first to avoid precision loss!
317 m_ll
= ((unsigned wxLongLong_t
) hi
) << 32;
318 m_ll
|= (unsigned wxLongLong_t
) lo
;
321 // default copy ctor is ok
325 // assignment operators
326 // from native 64 bit integer
327 wxULongLongNative
& operator=(unsigned wxLongLong_t ll
)
328 { m_ll
= ll
; return *this; }
330 // assignment operators from wxULongLongNative is ok
334 unsigned long GetHi() const
335 { return (unsigned long)(m_ll
>> 32); }
337 unsigned long GetLo() const
338 { return (unsigned long)m_ll
; }
340 // convert to native ulong long
341 unsigned wxLongLong_t
GetValue() const { return m_ll
; }
343 // convert to ulong with range checking in the debug mode (only!)
344 unsigned long ToULong() const
346 wxASSERT_MSG( m_ll
<= LONG_MAX
,
347 _T("wxULongLong to long conversion loss of precision") );
349 return (unsigned long)m_ll
;
354 wxULongLongNative
operator+(const wxULongLongNative
& ll
) const
355 { return wxULongLongNative(m_ll
+ ll
.m_ll
); }
356 wxULongLongNative
& operator+=(const wxULongLongNative
& ll
)
357 { m_ll
+= ll
.m_ll
; return *this; }
359 wxULongLongNative
operator+(const unsigned wxLongLong_t ll
) const
360 { return wxULongLongNative(m_ll
+ ll
); }
361 wxULongLongNative
& operator+=(const unsigned wxLongLong_t ll
)
362 { m_ll
+= ll
; return *this; }
365 wxULongLongNative
& operator++()
366 { m_ll
++; return *this; }
369 wxULongLongNative
operator++(int)
370 { wxULongLongNative
value(*this); m_ll
++; return value
; }
373 wxULongLongNative
operator-(const wxULongLongNative
& ll
) const
374 { return wxULongLongNative(m_ll
- ll
.m_ll
); }
375 wxULongLongNative
& operator-=(const wxULongLongNative
& ll
)
376 { m_ll
-= ll
.m_ll
; return *this; }
378 wxULongLongNative
operator-(const unsigned wxLongLong_t ll
) const
379 { return wxULongLongNative(m_ll
- ll
); }
380 wxULongLongNative
& operator-=(const unsigned wxLongLong_t ll
)
381 { m_ll
-= ll
; return *this; }
384 wxULongLongNative
& operator--()
385 { m_ll
--; return *this; }
388 wxULongLongNative
operator--(int)
389 { wxULongLongNative
value(*this); m_ll
--; return value
; }
393 wxULongLongNative
operator<<(int shift
) const
394 { return wxULongLongNative(m_ll
<< shift
);; }
395 wxULongLongNative
& operator<<=(int shift
)
396 { m_ll
<<= shift
; return *this; }
399 wxULongLongNative
operator>>(int shift
) const
400 { return wxULongLongNative(m_ll
>> shift
);; }
401 wxULongLongNative
& operator>>=(int shift
)
402 { m_ll
>>= shift
; return *this; }
405 wxULongLongNative
operator&(const wxULongLongNative
& ll
) const
406 { return wxULongLongNative(m_ll
& ll
.m_ll
); }
407 wxULongLongNative
& operator&=(const wxULongLongNative
& ll
)
408 { m_ll
&= ll
.m_ll
; return *this; }
410 wxULongLongNative
operator|(const wxULongLongNative
& ll
) const
411 { return wxULongLongNative(m_ll
| ll
.m_ll
); }
412 wxULongLongNative
& operator|=(const wxULongLongNative
& ll
)
413 { m_ll
|= ll
.m_ll
; return *this; }
415 wxULongLongNative
operator^(const wxULongLongNative
& ll
) const
416 { return wxULongLongNative(m_ll
^ ll
.m_ll
); }
417 wxULongLongNative
& operator^=(const wxULongLongNative
& ll
)
418 { m_ll
^= ll
.m_ll
; return *this; }
420 // multiplication/division
421 wxULongLongNative
operator*(const wxULongLongNative
& ll
) const
422 { return wxULongLongNative(m_ll
* ll
.m_ll
); }
423 wxULongLongNative
operator*(unsigned long l
) const
424 { return wxULongLongNative(m_ll
* l
); }
425 wxULongLongNative
& operator*=(const wxULongLongNative
& ll
)
426 { m_ll
*= ll
.m_ll
; return *this; }
427 wxULongLongNative
& operator*=(unsigned long l
)
428 { m_ll
*= l
; return *this; }
430 wxULongLongNative
operator/(const wxULongLongNative
& ll
) const
431 { return wxULongLongNative(m_ll
/ ll
.m_ll
); }
432 wxULongLongNative
operator/(unsigned long l
) const
433 { return wxULongLongNative(m_ll
/ l
); }
434 wxULongLongNative
& operator/=(const wxULongLongNative
& ll
)
435 { m_ll
/= ll
.m_ll
; return *this; }
436 wxULongLongNative
& operator/=(unsigned long l
)
437 { m_ll
/= l
; return *this; }
439 wxULongLongNative
operator%(const wxULongLongNative
& ll
) const
440 { return wxULongLongNative(m_ll
% ll
.m_ll
); }
441 wxULongLongNative
operator%(unsigned long l
) const
442 { return wxULongLongNative(m_ll
% l
); }
445 bool operator==(const wxULongLongNative
& ll
) const
446 { return m_ll
== ll
.m_ll
; }
447 bool operator==(unsigned long l
) const
448 { return m_ll
== l
; }
449 bool operator!=(const wxULongLongNative
& ll
) const
450 { return m_ll
!= ll
.m_ll
; }
451 bool operator!=(unsigned long l
) const
452 { return m_ll
!= l
; }
453 bool operator<(const wxULongLongNative
& ll
) const
454 { return m_ll
< ll
.m_ll
; }
455 bool operator<(unsigned long l
) const
457 bool operator>(const wxULongLongNative
& ll
) const
458 { return m_ll
> ll
.m_ll
; }
459 bool operator>(unsigned long l
) const
461 bool operator<=(const wxULongLongNative
& ll
) const
462 { return m_ll
<= ll
.m_ll
; }
463 bool operator<=(unsigned long l
) const
464 { return m_ll
<= l
; }
465 bool operator>=(const wxULongLongNative
& ll
) const
466 { return m_ll
>= ll
.m_ll
; }
467 bool operator>=(unsigned long l
) const
468 { return m_ll
>= l
; }
472 // return the string representation of this number
473 wxString
ToString() const;
475 // conversion to byte array: returns a pointer to static buffer!
476 void *asArray() const;
478 #if wxUSE_STD_IOSTREAM
480 friend wxSTD ostream
& operator<<(wxSTD ostream
&, const wxULongLongNative
&);
484 unsigned wxLongLong_t m_ll
;
487 #endif // wxUSE_LONGLONG_NATIVE
489 #if wxUSE_LONGLONG_WX
491 class WXDLLIMPEXP_BASE wxLongLongWx
495 // default ctor initializes to 0
500 #ifdef wxLONGLONG_TEST_MODE
504 #endif // wxLONGLONG_TEST_MODE
507 wxLongLongWx(long l
) { *this = l
; }
509 wxLongLongWx(long hi
, unsigned long lo
)
514 #ifdef wxLONGLONG_TEST_MODE
520 #endif // wxLONGLONG_TEST_MODE
523 // default copy ctor is ok in both cases
527 // assignment operators
529 wxLongLongWx
& operator=(long l
)
532 m_hi
= (l
< 0 ? -1l : 0l);
534 #ifdef wxLONGLONG_TEST_MODE
538 #endif // wxLONGLONG_TEST_MODE
543 wxLongLongWx
& Assign(double d
);
544 // can't have assignment operator from 2 longs
548 long GetHi() const { return m_hi
; }
550 unsigned long GetLo() const { return m_lo
; }
552 // get absolute value
553 wxLongLongWx
Abs() const { return wxLongLongWx(*this).Abs(); }
559 #ifdef wxLONGLONG_TEST_MODE
564 #endif // wxLONGLONG_TEST_MODE
569 // convert to long with range checking in the debug mode (only!)
572 wxASSERT_MSG( (m_hi
== 0l) || (m_hi
== -1l),
573 _T("wxLongLong to long conversion loss of precision") );
580 wxLongLongWx
operator+(const wxLongLongWx
& ll
) const;
581 wxLongLongWx
& operator+=(const wxLongLongWx
& ll
);
582 wxLongLongWx
operator+(long l
) const;
583 wxLongLongWx
& operator+=(long l
);
585 // pre increment operator
586 wxLongLongWx
& operator++();
588 // post increment operator
589 wxLongLongWx
& operator++(int) { return ++(*this); }
592 wxLongLongWx
operator-() const;
593 wxLongLongWx
& Negate();
596 wxLongLongWx
operator-(const wxLongLongWx
& ll
) const;
597 wxLongLongWx
& operator-=(const wxLongLongWx
& ll
);
599 // pre decrement operator
600 wxLongLongWx
& operator--();
602 // post decrement operator
603 wxLongLongWx
& operator--(int) { return --(*this); }
607 wxLongLongWx
operator<<(int shift
) const;
608 wxLongLongWx
& operator<<=(int shift
);
611 wxLongLongWx
operator>>(int shift
) const;
612 wxLongLongWx
& operator>>=(int shift
);
615 wxLongLongWx
operator&(const wxLongLongWx
& ll
) const;
616 wxLongLongWx
& operator&=(const wxLongLongWx
& ll
);
617 wxLongLongWx
operator|(const wxLongLongWx
& ll
) const;
618 wxLongLongWx
& operator|=(const wxLongLongWx
& ll
);
619 wxLongLongWx
operator^(const wxLongLongWx
& ll
) const;
620 wxLongLongWx
& operator^=(const wxLongLongWx
& ll
);
621 wxLongLongWx
operator~() const;
624 bool operator==(const wxLongLongWx
& ll
) const
625 { return m_lo
== ll
.m_lo
&& m_hi
== ll
.m_hi
; }
626 bool operator!=(const wxLongLongWx
& ll
) const
627 { return !(*this == ll
); }
628 bool operator<(const wxLongLongWx
& ll
) const;
629 bool operator>(const wxLongLongWx
& ll
) const;
630 bool operator<=(const wxLongLongWx
& ll
) const
631 { return *this < ll
|| *this == ll
; }
632 bool operator>=(const wxLongLongWx
& ll
) const
633 { return *this > ll
|| *this == ll
; }
635 bool operator<(long l
) const { return *this < wxLongLongWx(l
); }
636 bool operator>(long l
) const { return *this > wxLongLongWx(l
); }
637 bool operator==(long l
) const
639 return l
>= 0 ? (m_hi
== 0 && m_lo
== (unsigned long)l
)
640 : (m_hi
== -1 && m_lo
== (unsigned long)l
);
643 bool operator<=(long l
) const { return *this < l
|| *this == l
; }
644 bool operator>=(long l
) const { return *this > l
|| *this == l
; }
647 wxLongLongWx
operator*(const wxLongLongWx
& ll
) const;
648 wxLongLongWx
& operator*=(const wxLongLongWx
& ll
);
651 wxLongLongWx
operator/(const wxLongLongWx
& ll
) const;
652 wxLongLongWx
& operator/=(const wxLongLongWx
& ll
);
654 wxLongLongWx
operator%(const wxLongLongWx
& ll
) const;
656 void Divide(const wxLongLongWx
& divisor
,
657 wxLongLongWx
& quotient
,
658 wxLongLongWx
& remainder
) const;
662 // return the string representation of this number
663 wxString
ToString() const;
665 void *asArray() const;
667 #if wxUSE_STD_IOSTREAM
668 friend wxSTD ostream
& operator<<(wxSTD ostream
&, const wxLongLongWx
&);
669 #endif // wxUSE_STD_IOSTREAM
672 // long is at least 32 bits, so represent our 64bit number as 2 longs
674 long m_hi
; // signed bit is in the high part
677 #ifdef wxLONGLONG_TEST_MODE
680 wxASSERT( (m_ll
>> 32) == m_hi
&& (unsigned long)m_ll
== m_lo
);
684 #endif // wxLONGLONG_TEST_MODE
688 class WXDLLIMPEXP_BASE wxULongLongWx
692 // default ctor initializes to 0
697 #ifdef wxLONGLONG_TEST_MODE
701 #endif // wxLONGLONG_TEST_MODE
704 wxULongLongWx(unsigned long l
) { *this = l
; }
706 wxULongLongWx(unsigned long hi
, unsigned long lo
)
711 #ifdef wxLONGLONG_TEST_MODE
717 #endif // wxLONGLONG_TEST_MODE
720 // default copy ctor is ok in both cases
724 // assignment operators
726 wxULongLongWx
& operator=(unsigned long l
)
731 #ifdef wxLONGLONG_TEST_MODE
735 #endif // wxLONGLONG_TEST_MODE
740 // can't have assignment operator from 2 longs
744 unsigned long GetHi() const { return m_hi
; }
746 unsigned long GetLo() const { return m_lo
; }
748 // convert to long with range checking in the debug mode (only!)
749 unsigned long ToULong() const
751 wxASSERT_MSG( m_hi
== 0ul,
752 _T("wxULongLong to long conversion loss of precision") );
754 return (unsigned long)m_lo
;
759 wxULongLongWx
operator+(const wxULongLongWx
& ll
) const;
760 wxULongLongWx
& operator+=(const wxULongLongWx
& ll
);
761 wxULongLongWx
operator+(unsigned long l
) const;
762 wxULongLongWx
& operator+=(unsigned long l
);
764 // pre increment operator
765 wxULongLongWx
& operator++();
767 // post increment operator
768 wxULongLongWx
& operator++(int) { return ++(*this); }
770 // subraction (FIXME: should return wxLongLong)
771 wxULongLongWx
operator-(const wxULongLongWx
& ll
) const;
772 wxULongLongWx
& operator-=(const wxULongLongWx
& ll
);
774 // pre decrement operator
775 wxULongLongWx
& operator--();
777 // post decrement operator
778 wxULongLongWx
& operator--(int) { return --(*this); }
782 wxULongLongWx
operator<<(int shift
) const;
783 wxULongLongWx
& operator<<=(int shift
);
786 wxULongLongWx
operator>>(int shift
) const;
787 wxULongLongWx
& operator>>=(int shift
);
790 wxULongLongWx
operator&(const wxULongLongWx
& ll
) const;
791 wxULongLongWx
& operator&=(const wxULongLongWx
& ll
);
792 wxULongLongWx
operator|(const wxULongLongWx
& ll
) const;
793 wxULongLongWx
& operator|=(const wxULongLongWx
& ll
);
794 wxULongLongWx
operator^(const wxULongLongWx
& ll
) const;
795 wxULongLongWx
& operator^=(const wxULongLongWx
& ll
);
796 wxULongLongWx
operator~() const;
799 bool operator==(const wxULongLongWx
& ll
) const
800 { return m_lo
== ll
.m_lo
&& m_hi
== ll
.m_hi
; }
801 bool operator!=(const wxULongLongWx
& ll
) const
802 { return !(*this == ll
); }
803 bool operator<(const wxULongLongWx
& ll
) const;
804 bool operator>(const wxULongLongWx
& ll
) const;
805 bool operator<=(const wxULongLongWx
& ll
) const
806 { return *this < ll
|| *this == ll
; }
807 bool operator>=(const wxULongLongWx
& ll
) const
808 { return *this > ll
|| *this == ll
; }
810 bool operator<(unsigned long l
) const { return *this < wxULongLongWx(l
); }
811 bool operator>(unsigned long l
) const { return *this > wxULongLongWx(l
); }
812 bool operator==(unsigned long l
) const
814 return (m_hi
== 0 && m_lo
== (unsigned long)l
);
817 bool operator<=(unsigned long l
) const { return *this < l
|| *this == l
; }
818 bool operator>=(unsigned long l
) const { return *this > l
|| *this == l
; }
821 wxULongLongWx
operator*(const wxULongLongWx
& ll
) const;
822 wxULongLongWx
& operator*=(const wxULongLongWx
& ll
);
825 wxULongLongWx
operator/(const wxULongLongWx
& ll
) const;
826 wxULongLongWx
& operator/=(const wxULongLongWx
& ll
);
828 wxULongLongWx
operator%(const wxULongLongWx
& ll
) const;
830 void Divide(const wxULongLongWx
& divisor
,
831 wxULongLongWx
& quotient
,
832 wxULongLongWx
& remainder
) const;
836 // return the string representation of this number
837 wxString
ToString() const;
839 void *asArray() const;
841 #if wxUSE_STD_IOSTREAM
842 friend wxSTD ostream
& operator<<(wxSTD ostream
&, const wxULongLongWx
&);
843 #endif // wxUSE_STD_IOSTREAM
846 // long is at least 32 bits, so represent our 64bit number as 2 longs
851 #ifdef wxLONGLONG_TEST_MODE
854 wxASSERT( (m_ll
>> 32) == m_hi
&& (unsigned long)m_ll
== m_lo
);
857 unsigned wxLongLong_t m_ll
;
858 #endif // wxLONGLONG_TEST_MODE
861 #endif // wxUSE_LONGLONG_WX
863 // ----------------------------------------------------------------------------
865 // ----------------------------------------------------------------------------
867 inline bool operator<(long l
, const wxLongLong
& ll
) { return ll
> l
; }
868 inline bool operator>(long l
, const wxLongLong
& ll
) { return ll
< l
; }
869 inline bool operator<=(long l
, const wxLongLong
& ll
) { return ll
>= l
; }
870 inline bool operator>=(long l
, const wxLongLong
& ll
) { return ll
<= l
; }
871 inline bool operator==(long l
, const wxLongLong
& ll
) { return ll
== l
; }
872 inline bool operator!=(long l
, const wxLongLong
& ll
) { return ll
!= l
; }
874 inline wxLongLong
operator+(long l
, const wxLongLong
& ll
) { return ll
+ l
; }
875 inline wxLongLong
operator-(long l
, const wxLongLong
& ll
)
877 return wxLongLong(l
) - ll
;
880 inline bool operator<(unsigned long l
, const wxULongLong
& ull
) { return ull
> l
; }
881 inline bool operator>(unsigned long l
, const wxULongLong
& ull
) { return ull
< l
; }
882 inline bool operator<=(unsigned long l
, const wxULongLong
& ull
) { return ull
>= l
; }
883 inline bool operator>=(unsigned long l
, const wxULongLong
& ull
) { return ull
<= l
; }
884 inline bool operator==(unsigned long l
, const wxULongLong
& ull
) { return ull
== l
; }
885 inline bool operator!=(unsigned long l
, const wxULongLong
& ull
) { return ull
!= l
; }
887 inline wxULongLong
operator+(unsigned long l
, const wxULongLong
& ull
) { return ull
+ l
; }
889 // FIXME: this should return wxLongLong
890 inline wxULongLong
operator-(unsigned long l
, const wxULongLong
& ull
)
892 return wxULongLong(l
) - ull
;
895 #endif // _WX_LONGLONG_H