Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
ulonglong Class Reference

#include <ulonglong.hh>

Public Member Functions

 ulonglong ()
 Default contructor.
 
 ulonglong (const uint u1_, const uint u2_)
 Constructor.
 
 ulonglong (const int u2_)
 Constructor.
 
 ulonglong (const uint u2_)
 Constructor.
 
 ulonglong (const double d)
 Constructor.
 
ulonglongoperator= (const int i)
 Assignment operator.
 
ulonglongoperator= (const uint i)
 Assignment operator.
 
ulonglongoperator= (const double d)
 Assignment operator.
 
 operator double () const
 cast operator
 
ulonglongoperator-- ()
 prefix decrement
 
ulonglongoperator++ ()
 prefix increment
 
ulonglong operator-- (int)
 postfix decrement
 
ulonglong operator++ (int)
 postfix increment
 
ulonglong operator- (const int x)
 
ulonglong operator+ (const int x)
 
ulonglong operator- (const ulonglong &b)
 
ulonglong operator+ (const ulonglong &b)
 
ulonglongoperator+= (const int x)
 
ulonglongoperator-= (const int x)
 
ulonglongoperator+= (const uint x)
 
ulonglongoperator-= (const uint x)
 
ulonglongoperator-= (const ulonglong &x)
 
ulonglongoperator+= (const ulonglong &x)
 
ulonglongoperator&= (const ulonglong &x)
 
ulonglongoperator|= (const ulonglong &x)
 
ulonglongoperator^= (const ulonglong &x)
 
bool operator== (const ulonglong &b) const
 
bool operator!= (const ulonglong &b) const
 
bool operator< (const ulonglong &b) const
 
bool operator<= (const ulonglong &b) const
 
bool operator> (const ulonglong &b) const
 
bool operator>= (const ulonglong &b) const
 
uint operator[] (const int i)
 
uint msw () const
 most significant value
 
uint lsw () const
 least significant value
 
std::ostream & write (std::ostream &out) const
 
std::istream & read (std::istream &in)
 

Static Public Member Functions

static ulonglong distance (const ulonglong &a, const ulonglong &b)
 distance between 2 values
 

Public Attributes

uint u1
 
uint u2
 

Private Types

typedef unsigned int uint
 

Detailed Description

Definition at line 11 of file ulonglong.hh.

Member Typedef Documentation

◆ uint

unsigned int ulonglong::uint
private

Definition at line 13 of file ulonglong.hh.

Constructor & Destructor Documentation

◆ ulonglong() [1/5]

ulonglong::ulonglong ( )
inline

Default contructor.

Definition at line 23 of file ulonglong.hh.

23 :
24 u1(0),
25 u2(0)
26 {}

◆ ulonglong() [2/5]

ulonglong::ulonglong ( const uint u1_,
const uint u2_ )
inline

Constructor.

Parameters
u1_most significant value
u2_least significant value

Definition at line 33 of file ulonglong.hh.

33 :
34 u1(u1_),
35 u2(u2_)
36 {}

◆ ulonglong() [3/5]

ulonglong::ulonglong ( const int u2_)
inline

Constructor.

Parameters
u2_least significant value

Definition at line 42 of file ulonglong.hh.

42 :
43 u1(0),
44 u2(u2_)
45 {}

◆ ulonglong() [4/5]

ulonglong::ulonglong ( const uint u2_)
inline

Constructor.

Parameters
u2_least significant value

Definition at line 51 of file ulonglong.hh.

51 :
52 u1(0),
53 u2(u2_)
54 {}

◆ ulonglong() [5/5]

ulonglong::ulonglong ( const double d)
inline

Constructor.

Parameters
dvalue

Definition at line 60 of file ulonglong.hh.

60 :
61 u1(0),
62 u2(0)
63 {
64 *this = d;
65 }

Member Function Documentation

◆ operator=() [1/3]

ulonglong & ulonglong::operator= ( const int i)
inline

Assignment operator.

Definition at line 70 of file ulonglong.hh.

71 {
72 u1 = 0;
73 u2 = (uint) i;
74 return *this;
75 }
unsigned int uint
Definition ulonglong.hh:13

◆ operator=() [2/3]

ulonglong & ulonglong::operator= ( const uint i)
inline

Assignment operator.

Definition at line 80 of file ulonglong.hh.

81 {
82 u1 = 0;
83 u2 = i;
84 return *this;
85 }

◆ operator=() [3/3]

ulonglong & ulonglong::operator= ( const double d)
inline

Assignment operator.

Definition at line 90 of file ulonglong.hh.

91 {
92 if (d < (double) std::numeric_limits<uint>::max()) {
93 u1 = 0;
94 u2 = (uint) d;
95 } else {
96 u1 = (uint) (d / ((double) std::numeric_limits<uint>::max()));
97 u2 = (uint) (d - ((double) u1) * (double) std::numeric_limits<uint>::max());
98 }
99 return *this;
100 }

◆ operator double()

ulonglong::operator double ( ) const
inline

cast operator

Definition at line 105 of file ulonglong.hh.

106 {
107 return ((double) u1) * ((double) std::numeric_limits<uint>::max()) + ((double) u2);
108 }

◆ operator--() [1/2]

ulonglong & ulonglong::operator-- ( )
inline

prefix decrement

Definition at line 113 of file ulonglong.hh.

114 {
115 if (u2 > 0)
116 --u2;
117 else {
118 --u1;
119 u2 = std::numeric_limits<uint>::max();
120 }
121 return *this;
122 }

◆ operator++() [1/2]

ulonglong & ulonglong::operator++ ( )
inline

prefix increment

Definition at line 127 of file ulonglong.hh.

128 {
129 if (u2 < std::numeric_limits<uint>::max())
130 ++u2;
131 else {
132 ++u1;
133 u2 = 0;
134 }
135 return *this;
136 }

◆ operator--() [2/2]

ulonglong ulonglong::operator-- ( int )
inline

postfix decrement

Definition at line 141 of file ulonglong.hh.

142 {
143 ulonglong a(*this);
144 if (u2 > 0)
145 u2--;
146 else {
147 u1--;
148 u2 = std::numeric_limits<uint>::max();
149 }
150 return a;
151 }
const double a

◆ operator++() [2/2]

ulonglong ulonglong::operator++ ( int )
inline

postfix increment

Definition at line 156 of file ulonglong.hh.

157 {
158 ulonglong a(*this);
159 if (u2 < std::numeric_limits<uint>::max())
160 u2++;
161 else {
162 u1++;
163 u2 = 0;
164 }
165 return a;
166 }

◆ operator-() [1/2]

ulonglong ulonglong::operator- ( const int x)
inline

Definition at line 168 of file ulonglong.hh.

169 {
170 ulonglong b(*this);
171 b -= x;
172 return b;
173 }

◆ operator+() [1/2]

ulonglong ulonglong::operator+ ( const int x)
inline

Definition at line 175 of file ulonglong.hh.

176 {
177 ulonglong b(*this);
178 b += x;
179 return b;
180 }

◆ operator-() [2/2]

ulonglong ulonglong::operator- ( const ulonglong & b)
inline

Definition at line 182 of file ulonglong.hh.

183 {
184 ulonglong a(*this);
185 a.u1 -= b.u1;
186 return (a -= b.u2);
187 }

◆ operator+() [2/2]

ulonglong ulonglong::operator+ ( const ulonglong & b)
inline

Definition at line 189 of file ulonglong.hh.

190 {
191 ulonglong a(*this);
192 a.u1 += b.u1;
193 return (a += b.u2);
194 }

◆ operator+=() [1/3]

ulonglong & ulonglong::operator+= ( const int x)
inline

Definition at line 196 of file ulonglong.hh.

197 {
198 if (x >= 0)
199 return (*this += (uint) x);
200 else
201 return (*this -= (uint) -x);
202 }

◆ operator-=() [1/3]

ulonglong & ulonglong::operator-= ( const int x)
inline

Definition at line 204 of file ulonglong.hh.

205 {
206 if (x >= 0)
207 return (*this -= (uint) x);
208 else
209 return (*this += (uint) -x);
210 }

◆ operator+=() [2/3]

ulonglong & ulonglong::operator+= ( const uint x)
inline

Definition at line 212 of file ulonglong.hh.

213 {
214 uint l = std::numeric_limits<uint>::max() - u2;
215
216 if (l >= x)
217 u2 += x;
218 else {
219 u1++;
220 u2 = x - l - 1;
221 }
222
223 return *this;
224 }

◆ operator-=() [2/3]

ulonglong & ulonglong::operator-= ( const uint x)
inline

Definition at line 226 of file ulonglong.hh.

227 {
228 if (u2 >= x)
229 u2 -= x;
230 else {
231 u1--;
232 u2 = (std::numeric_limits<uint>::max() - x) + u2 + 1;
233 }
234 return *this;
235 }

◆ operator-=() [3/3]

ulonglong & ulonglong::operator-= ( const ulonglong & x)
inline

Definition at line 237 of file ulonglong.hh.

238 {
239 u1 -= x.u1;
240 *this -= x.u2;
241 return *this;
242 }

◆ operator+=() [3/3]

ulonglong & ulonglong::operator+= ( const ulonglong & x)
inline

Definition at line 244 of file ulonglong.hh.

245 {
246 *this += x.u2;
247 u1 += x.u1;
248 return *this;
249 }

◆ operator&=()

ulonglong & ulonglong::operator&= ( const ulonglong & x)
inline

Definition at line 251 of file ulonglong.hh.

252 {
253 u1 &= x.u1;
254 u2 &= x.u2;
255 return *this;
256 }

◆ operator|=()

ulonglong & ulonglong::operator|= ( const ulonglong & x)
inline

Definition at line 258 of file ulonglong.hh.

259 {
260 u1 |= x.u1;
261 u2 |= x.u2;
262 return *this;
263 }

◆ operator^=()

ulonglong & ulonglong::operator^= ( const ulonglong & x)
inline

Definition at line 265 of file ulonglong.hh.

266 {
267 u1 ^= x.u1;
268 u2 ^= x.u2;
269 return *this;
270 }

◆ operator==()

bool ulonglong::operator== ( const ulonglong & b) const
inline

Definition at line 272 of file ulonglong.hh.

273 {
274 return (u1 == b.u1 && u2 == b.u2);
275 }

◆ operator!=()

bool ulonglong::operator!= ( const ulonglong & b) const
inline

Definition at line 277 of file ulonglong.hh.

278 {
279 return (u1 != b.u1 || u2 != b.u2);
280 }

◆ operator<()

bool ulonglong::operator< ( const ulonglong & b) const
inline

Definition at line 282 of file ulonglong.hh.

283 {
284 if (u1 == b.u1)
285 return (u2 < b.u2);
286 else
287 return (u1 < b.u1);
288 }

◆ operator<=()

bool ulonglong::operator<= ( const ulonglong & b) const
inline

Definition at line 290 of file ulonglong.hh.

291 {
292 if (u1 == b.u1)
293 return (u2 <= b.u2);
294 else
295 return (u1 <= b.u1);
296 }

◆ operator>()

bool ulonglong::operator> ( const ulonglong & b) const
inline

Definition at line 298 of file ulonglong.hh.

299 {
300 if (u1 == b.u1)
301 return (u2 > b.u2);
302 else
303 return (u1 > b.u1);
304 }

◆ operator>=()

bool ulonglong::operator>= ( const ulonglong & b) const
inline

Definition at line 306 of file ulonglong.hh.

306 {
307 if (u1 == b.u1)
308 return (u2 >= b.u2);
309 else
310 return (u1 >= b.u1);
311 }

◆ operator[]()

uint ulonglong::operator[] ( const int i)
inline

Definition at line 313 of file ulonglong.hh.

313 {
314 assert(i == 0 || i == 1);
315 if (i == 0)
316 return u1;
317 else
318 return u2;
319 }

◆ msw()

uint ulonglong::msw ( ) const
inline

most significant value

Definition at line 321 of file ulonglong.hh.

◆ lsw()

uint ulonglong::lsw ( ) const
inline

least significant value

Definition at line 322 of file ulonglong.hh.

◆ write()

std::ostream & ulonglong::write ( std::ostream & out) const
inline

Definition at line 324 of file ulonglong.hh.

325 {
326 std::ios::fmtflags oldFlags = out.flags();
327 out << std::hex << std::setfill('0') << std::setw(8) << u1 << std::setw(8) << u2;
328 out.flags(oldFlags);
329 return out;
330 }

◆ read()

std::istream & ulonglong::read ( std::istream & in)
inline

Definition at line 332 of file ulonglong.hh.

333 {
334 in >> u1 >> u2;
335 return in;
336 }

◆ distance()

static ulonglong ulonglong::distance ( const ulonglong & a,
const ulonglong & b )
inlinestatic

distance between 2 values

Parameters
afirst value
bsecond value
Returns
distance

Definition at line 344 of file ulonglong.hh.

345 {
346 ulonglong value;
347
348 value.u1 = std::max(a.u1,b.u1) - std::min(a.u1,b.u1);
349 value.u2 = std::max(a.u2,b.u2) - std::min(a.u2,b.u2);
350
351 if ((a.u1 < b.u1 && a.u2 > b.u2) ||
352 (a.u1 > b.u1 && a.u2 < b.u2)) {
353 --value.u1;
354 value.u2 = std::numeric_limits<uint>::max() - value.u2 + 1;
355 }
356
357 return value;
358 }

Member Data Documentation

◆ u1

uint ulonglong::u1

Definition at line 16 of file ulonglong.hh.

◆ u2

uint ulonglong::u2

Definition at line 17 of file ulonglong.hh.


The documentation for this class was generated from the following file: