]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/longlong.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxLongLong
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
11 This class represents a signed 64 bit long number. It is implemented using the
12 native 64 bit type where available (machines with 64 bit longs or compilers
13 which have (an analog of) @e long long type) and uses the emulation code in
14 the other cases which ensures that it is the most efficient solution for
15 working with 64 bit integers independently of the architecture.
17 wxLongLong defines all usual arithmetic operations such as addition,
18 subtraction, bitwise shifts and logical operations as well as multiplication
19 and division (not yet for the machines without native @e long long).
20 It also has operators for implicit construction from and conversion to the native
21 @e long long type if it exists and @e long.
23 You would usually use this type in exactly the same manner as any other
24 (built-in) arithmetic type. Note that wxLongLong is a signed type, if you
25 want unsigned values use wxULongLong which has exactly the same API as
26 wxLongLong except when explicitly mentioned otherwise.
28 If a native (i.e. supported directly by the compiler) 64 bit integer type was
29 found to exist, @e wxLongLong_t macro will be defined to correspond to it.
30 Also, in this case only, two additional macros will be defined:
31 - wxLongLongFmtSpec() for printing 64 bit integers using the standard @c printf()
32 function (but see also wxLongLong::ToString for a more portable solution);
33 - wxLL() for defining 64 bit integer compile-time constants.
42 Default constructor initializes the object to 0.
47 Constructor from native long long (only for compilers supporting it).
49 wxLongLong(wxLongLong_t ll
);
52 Constructor from 2 longs: the high and low part are combined into one
55 wxLongLong(long hi
, unsigned long lo
);
59 Returns an absolute value of wxLongLong - either making a copy (const version)
60 or modifying it in place (the second one). Not in wxULongLong.
62 wxLongLong
Abs() const;
67 This allows to convert a double value to wxLongLong type.
69 Such conversion is not always possible in which case the result will be
70 silently truncated in a platform-dependent way. Not in wxULongLong.
72 wxLongLong
Assign(double d
);
75 Returns the high 32 bits of 64 bit integer.
80 Returns the low 32 bits of 64 bit integer.
82 unsigned long GetLo() const;
85 Convert to native long long (only for compilers supporting it).
87 wxLongLong_t
GetValue() const;
90 Returns the value as @c double.
92 double ToDouble() const;
95 Truncate wxLongLong to long. If the conversion loses data (i.e. the wxLongLong
96 value is outside the range of built-in long type), an assert will be triggered
102 Returns the string representation of a wxLongLong.
104 wxString
ToString() const;
108 Adds 2 wxLongLongs together and returns the result.
110 wxLongLong
operator+(const wxLongLong
& ll
) const;
113 Add another wxLongLong to this one.
115 wxLongLong
& operator+(const wxLongLong
& ll
);
119 Subtracts 2 wxLongLongs and returns the result.
121 wxLongLong
operator-(const wxLongLong
& ll
) const;
124 Subtracts another wxLongLong from this one.
126 wxLongLong
& operator-(const wxLongLong
& ll
);
131 Pre/post increment operator.
133 wxLongLong
operator++();
134 wxLongLong
operator++(int);
139 Pre/post decrement operator.
141 wxLongLong
operator--();
142 wxLongLong
operator--(int);
146 Returns the value of this wxLongLong with opposite sign. Not in wxULongLong.
148 wxLongLong
operator-() const;
151 Assignment operator from unsigned long long. The sign bit will be copied too.
155 wxLongLong
& operator=(const wxULongLong
& ll
);
158 Assignment operator from native long long (only for compilers supporting it).
160 wxLongLong
& operator=(wxLongLong_t ll
);
163 Assignment operator from native unsigned long long (only for compilers supporting it).
167 wxLongLong
& operator=(wxULongLong_t ll
);
170 Assignment operator from long.
174 wxLongLong
& operator=(long l
);
177 Assignment operator from unsigned long.
181 wxLongLong
& operator=(unsigned long l
);
189 This class represents an unsigned 64 bit long number.
191 Since wxULongLong has exactly the same API as wxLongLong, please refer
192 to wxLongLong documentation (this page exists only as redirection).
202 // ============================================================================
203 // Global functions/macros
204 // ============================================================================
206 /** @addtogroup group_funcmacro_misc */
210 This macro is defined to contain the @c printf() format specifier using
211 which 64 bit integer numbers (i.e. those of type @c wxLongLong_t) can be
212 printed. Example of using it:
216 wxLongLong_t ll = wxLL(0x1234567890abcdef);
217 printf("Long long = %" wxLongLongFmtSpec "x\n", ll);
223 @header{wx/longlong.h}
225 #define wxLongLongFmtSpec
228 This macro is defined for the platforms with a native 64 bit integer type
229 and allow the use of 64 bit compile time constants:
233 wxLongLong_t ll = wxLL(0x1234567890abcdef);
237 @see wxULL(), wxLongLong
239 @header{wx/longlong.h}
241 wxLongLong_t
wxLL(number
);
244 This macro is defined for the platforms with a native 64 bit integer type
245 and allow the use of 64 bit compile time constants:
249 unsigned wxLongLong_t ll = wxULL(0x1234567890abcdef);
253 @see wxLL(), wxLongLong
255 @header{wx/longlong.h}
257 wxLongLong_t
wxULL(number
);