]>
git.saurik.com Git - wxWidgets.git/blob - interface/longlong.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxLongLong
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 This class represents a signed 64 bit long number. It is implemented using the
14 native 64 bit type where available (machines with 64 bit longs or compilers
15 which have (an analog of) @e long long type) and uses the emulation code in
16 the other cases which ensures that it is the most efficient solution for
17 working with 64 bit integers independently of the architecture.
19 wxLongLong defines all usual arithmetic operations such as addition,
20 subtraction, bitwise shifts and logical operations as well as multiplication
21 and division (not yet for the machines without native @e long long). It
22 also has operators for implicit construction from and conversion to the native
23 @e long long type if it exists and @e long.
25 You would usually use this type in exactly the same manner as any other
26 (built-in) arithmetic type. Note that wxLongLong is a signed type, if you
27 want unsigned values use wxULongLong which has exactly the same API as
28 wxLongLong except when explicitly mentioned otherwise.
30 If a native (i.e. supported directly by the compiler) 64 bit integer type was
31 found to exist, @e wxLongLong_t macro will be defined to correspond to it.
32 Also, in this case only, two additional macros will be defined:
33 wxLongLongFmtSpec() for printing 64 bit integers
34 using the standard @c printf() function (but see also
35 wxLongLong::ToString for a more portable solution) and
36 wxLL() for defining 64 bit integer compile-time constants.
45 Constructor from 2 longs: the high and low part are combined into one
48 wxLongLong(long hi
, unsigned long lo
);
52 Returns an absolute value of wxLongLong - either making a copy (const version)
53 or modifying it in place (the second one). Not in wxULongLong.
56 const wxLongLong
& Abs();
60 This allows to convert a double value to wxLongLong type. Such conversion is
61 not always possible in which case the result will be silently truncated in a
62 platform-dependent way. Not in wxULongLong.
64 wxLongLong
Assign(double d
);
67 Returns the high 32 bits of 64 bit integer.
72 Returns the low 32 bits of 64 bit integer.
74 unsigned long GetLo() const;
77 Convert to native long long (only for compilers supporting it)
79 wxLongLong_t
GetValue() const;
82 Returns the value as @c double.
84 double ToDouble() const;
87 Truncate wxLongLong to long. If the conversion loses data (i.e. the wxLongLong
88 value is outside the range of built-in long type), an assert will be triggered
94 Returns the string representation of a wxLongLong.
96 wxString
ToString() const;
99 Adds 2 wxLongLongs together and returns the result.
101 wxLongLong
operator+(const wxLongLong
& ll
) const;
105 Pre/post increment operator.
107 wxLongLong
operator++();
108 wxLongLong
operator++(int );
112 Add another wxLongLong to this one.
114 wxLongLong
operator+(const wxLongLong
& ll
);
117 Subtracts 2 wxLongLongs and returns the result.
119 wxLongLong
operator-(const wxLongLong
& ll
) const;
123 Pre/post decrement operator.
125 wxLongLong
operator--();
126 wxLongLong
operator--(int );
130 Subtracts another wxLongLong from this one.
132 wxLongLong
operator-(const wxLongLong
& ll
);
135 Assignment operator from unsigned long long. The sign bit will be copied too.
139 wxLongLong
& operator operator=(const wxULongLong
& ll
);
144 // ============================================================================
145 // Global functions/macros
146 // ============================================================================
148 /** @ingroup group_funcmacro_misc */
152 This macro is defined to contain the @c printf() format specifier using
153 which 64 bit integer numbers (i.e. those of type @c wxLongLong_t) can be
154 printed. Example of using it:
158 wxLongLong_t ll = wxLL(0x1234567890abcdef);
159 printf("Long long = %" wxLongLongFmtSpec "x\n", ll);
165 @header{wx/longlong.h}
167 #define wxLongLongFmtSpec
170 This macro is defined for the platforms with a native 64 bit integer type
171 and allow the use of 64 bit compile time constants:
175 wxLongLong_t ll = wxLL(0x1234567890abcdef);
179 @see wxULL(), wxLongLong
181 @header{wx/longlong.h}
183 wxLongLong_t
wxLL(number
);
186 This macro is defined for the platforms with a native 64 bit integer type
187 and allow the use of 64 bit compile time constants:
191 unsigned wxLongLong_t ll = wxULL(0x1234567890abcdef);
195 @see wxLL(), wxLongLong
197 @header{wx/longlong.h}
199 wxLongLong_t
wxULL(number
);