1 #ifndef __ANTARESDAQ__ULONGLONG__
2 #define __ANTARESDAQ__ULONGLONG__
92 if (d < (
double) std::numeric_limits<uint>::max()) {
96 u1 = (
uint) (d / ((
double) std::numeric_limits<uint>::max()));
97 u2 = (
uint) (d - ((
double)
u1) * (
double) std::numeric_limits<uint>::max());
105 operator double()
const
107 return ((
double)
u1) * ((double) std::numeric_limits<uint>::max()) + ((
double)
u2);
119 u2 = std::numeric_limits<uint>::max();
129 if (
u2 < std::numeric_limits<uint>::max())
148 u2 = std::numeric_limits<uint>::max();
159 if (
u2 < std::numeric_limits<uint>::max())
199 return (*
this += (
uint)
x);
201 return (*
this -= (
uint) -
x);
207 return (*
this -= (
uint)
x);
209 return (*
this += (
uint) -
x);
214 uint l = std::numeric_limits<uint>::max() -
u2;
232 u2 = (std::numeric_limits<uint>::max() -
x) +
u2 + 1;
314 assert(i == 0 || i == 1);
324 std::ostream&
write(std::ostream& out)
const
326 std::ios::fmtflags oldFlags = out.flags();
327 out << std::hex << std::setfill(
'0') << std::setw(8) <<
u1 << std::setw(8) <<
u2;
332 std::istream&
read(std::istream& in)
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);
351 if ((
a.u1 < b.
u1 &&
a.u2 > b.
u2) ||
352 (
a.u1 > b.
u1 &&
a.u2 < b.
u2)) {
354 value.
u2 = std::numeric_limits<uint>::max() - value.
u2 + 1;
ulonglong & operator-=(const ulonglong &x)
ulonglong(const int u2_)
Constructor.
ulonglong & operator-=(const int x)
bool operator>=(const ulonglong &b) const
ulonglong(const uint u2_)
Constructor.
ulonglong & operator=(const double d)
Assignment operator.
uint operator[](const int i)
ulonglong & operator-=(const uint x)
bool operator<=(const ulonglong &b) const
uint msw() const
most significant value
ulonglong operator-(const int x)
ulonglong & operator+=(const ulonglong &x)
ulonglong(const uint u1_, const uint u2_)
Constructor.
bool operator<(const ulonglong &b) const
ulonglong & operator--()
prefix decrement
ulonglong & operator+=(const int x)
ulonglong & operator&=(const ulonglong &x)
ulonglong operator-(const ulonglong &b)
ulonglong operator++(int)
postfix increment
static ulonglong distance(const ulonglong &a, const ulonglong &b)
distance between 2 values
bool operator==(const ulonglong &b) const
ulonglong operator--(int)
postfix decrement
ulonglong & operator++()
prefix increment
ulonglong & operator+=(const uint x)
ulonglong(const double d)
Constructor.
ulonglong operator+(const ulonglong &b)
ulonglong & operator|=(const ulonglong &x)
bool operator!=(const ulonglong &b) const
ulonglong()
Default contructor.
ulonglong & operator=(const uint i)
Assignment operator.
std::istream & read(std::istream &in)
uint lsw() const
least significant value
ulonglong & operator=(const int i)
Assignment operator.
ulonglong operator+(const int x)
ulonglong & operator^=(const ulonglong &x)
bool operator>(const ulonglong &b) const
std::ostream & write(std::ostream &out) const
std::istream & operator>>(std::istream &in, ulonglong &a)
ulonglong operator|(const ulonglong &a, const ulonglong &b)
ulonglong operator^(const ulonglong &a, const ulonglong &b)
ulonglong operator&(const ulonglong &a, const ulonglong &b)
std::ostream & operator<<(std::ostream &out, const ulonglong &a)