]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/longlong.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxLongLong
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
12 This class represents a signed 64 bit long number. It is implemented using the
13 native 64 bit type where available (machines with 64 bit longs or compilers
14 which have (an analog of) @e long long type) and uses the emulation code in
15 the other cases which ensures that it is the most efficient solution for
16 working with 64 bit integers independently of the architecture.
18 wxLongLong defines all usual arithmetic operations such as addition,
19 subtraction, bitwise shifts and logical operations as well as multiplication
20 and division (not yet for the machines without native @e long long). It
21 also has operators for implicit construction from and conversion to the native
22 @e long long type if it exists and @e long.
24 You would usually use this type in exactly the same manner as any other
25 (built-in) arithmetic type. Note that wxLongLong is a signed type, if you
26 want unsigned values use wxULongLong which has exactly the same API as
27 wxLongLong except when explicitly mentioned otherwise.
29 If a native (i.e. supported directly by the compiler) 64 bit integer type was
30 found to exist, @e wxLongLong_t macro will be defined to correspond to it.
31 Also, in this case only, two additional macros will be defined:
32 - wxLongLongFmtSpec() for printing 64 bit integers using the standard @c printf()
33 function (but see also wxLongLong::ToString for a more portable solution);
34 - wxLL() for defining 64 bit integer compile-time constants.
43 Default constructor initializes the object to 0.
48 Constructor from native long long (only for compilers supporting it).
50 wxLongLong(wxLongLong_t ll
);
53 Constructor from 2 longs: the high and low part are combined into one
56 wxLongLong(long hi
, unsigned long lo
);
60 Returns an absolute value of wxLongLong - either making a copy (const version)
61 or modifying it in place (the second one). Not in wxULongLong.
63 wxLongLong
Abs() const;
68 This allows to convert a double value to wxLongLong type.
70 Such conversion is not always possible in which case the result will be
71 silently truncated in a platform-dependent way. Not in wxULongLong.
73 wxLongLong
Assign(double d
);
76 Returns the high 32 bits of 64 bit integer.
81 Returns the low 32 bits of 64 bit integer.
83 unsigned long GetLo() const;
86 Convert to native long long (only for compilers supporting it).
88 wxLongLong_t
GetValue() const;
91 Returns the value as @c double.
93 double ToDouble() const;
96 Truncate wxLongLong to long. If the conversion loses data (i.e. the wxLongLong
97 value is outside the range of built-in long type), an assert will be triggered
103 Returns the string representation of a wxLongLong.
105 wxString
ToString() const;
109 Adds 2 wxLongLongs together and returns the result.
111 wxLongLong
operator+(const wxLongLong
& ll
) const;
114 Add another wxLongLong to this one.
116 wxLongLong
& operator+(const wxLongLong
& ll
);
120 Subtracts 2 wxLongLongs and returns the result.
122 wxLongLong
operator-(const wxLongLong
& ll
) const;
125 Subtracts another wxLongLong from this one.
127 wxLongLong
& operator-(const wxLongLong
& ll
);
132 Pre/post increment operator.
134 wxLongLong
operator++();
135 wxLongLong
operator++(int);
140 Pre/post decrement operator.
142 wxLongLong
operator--();
143 wxLongLong
operator--(int);
147 Returns the value of this wxLongLong with opposite sign. Not in wxULongLong.
149 wxLongLong
operator-() const;
152 Assignment operator from unsigned long long. The sign bit will be copied too.
156 wxLongLong
& operator=(const wxULongLong
& ll
);
159 Assignment operator from native long long (only for compilers supporting it).
161 wxLongLong
& operator=(wxLongLong_t ll
);
164 Assignment operator from native unsigned long long (only for compilers supporting it).
168 wxLongLong
& operator=(wxULongLong_t ll
);
171 Assignment operator from long.
175 wxLongLong
& operator=(long l
);
178 Assignment operator from unsigned long.
182 wxLongLong
& operator=(unsigned long l
);
188 // ============================================================================
189 // Global functions/macros
190 // ============================================================================
192 /** @ingroup group_funcmacro_misc */
196 This macro is defined to contain the @c printf() format specifier using
197 which 64 bit integer numbers (i.e. those of type @c wxLongLong_t) can be
198 printed. Example of using it:
202 wxLongLong_t ll = wxLL(0x1234567890abcdef);
203 printf("Long long = %" wxLongLongFmtSpec "x\n", ll);
209 @header{wx/longlong.h}
211 #define wxLongLongFmtSpec
214 This macro is defined for the platforms with a native 64 bit integer type
215 and allow the use of 64 bit compile time constants:
219 wxLongLong_t ll = wxLL(0x1234567890abcdef);
223 @see wxULL(), wxLongLong
225 @header{wx/longlong.h}
227 wxLongLong_t
wxLL(number
);
230 This macro is defined for the platforms with a native 64 bit integer type
231 and allow the use of 64 bit compile time constants:
235 unsigned wxLongLong_t ll = wxULL(0x1234567890abcdef);
239 @see wxLL(), wxLongLong
241 @header{wx/longlong.h}
243 wxLongLong_t
wxULL(number
);