CPN
Computational Process Networks
uint128_t.h
Go to the documentation of this file.
1 //=============================================================================
2 // Computational Process Networks class library
3 // Copyright (C) 1997-2006 Gregory E. Allen and The University of Texas
4 //
5 // This library is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU Library General Public License as published
7 // by the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Library General Public License for more details.
14 //
15 // The GNU Public License is available in the file LICENSE, or you
16 // can write to the Free Software Foundation, Inc., 59 Temple Place -
17 // Suite 330, Boston, MA 02111-1307, USA, or you can find it on the
18 // World Wide Web at http://www.fsf.org.
19 //=============================================================================
27 #ifndef UINT128_T_H
28 #define UINT128_T_H
29 #pragma once
30 #include <cpn/common.h>
31 struct uint128_t {
32  uint128_t(uint64_t h, uint64_t l) : high(h), low(l) {}
33  uint128_t(uint64_t v) : high(0), low(v) {}
34  uint128_t() : high(0), low(0) {}
35  uint64_t high, low;
36 };
37 
38 inline bool operator<(const uint128_t &l, const uint128_t &r) {
39  if (l.high == r.high) { return l.low < r.low; }
40  else { return l.high < r.high; }
41 }
42 inline bool operator>=(const uint128_t &l, const uint128_t &r) { return !(l < r); }
43 inline bool operator<=(const uint128_t &l, const uint128_t &r) { return !(r < l); }
44 inline bool operator>(const uint128_t &l, const uint128_t &r) { return (r < l); }
45 inline bool operator==(const uint128_t &l, const uint128_t &r) {
46  return (l.high == r.high && l.low == r.low);
47 }
48 inline bool operator!=(const uint128_t &l, const uint128_t &r) { return !(r == l); }
49 #endif
uint128_t(uint64_t v)
Definition: uint128_t.h:33
uint128_t()
Definition: uint128_t.h:34
uint64_t high
Definition: uint128_t.h:35
bool operator<=(const uint128_t &l, const uint128_t &r)
Definition: uint128_t.h:43
uint128_t(uint64_t h, uint64_t l)
Definition: uint128_t.h:32
bool operator==(const uint128_t &l, const uint128_t &r)
Definition: uint128_t.h:45
uint64_t low
Definition: uint128_t.h:35
bool operator>=(const uint128_t &l, const uint128_t &r)
Definition: uint128_t.h:42
bool operator<(const uint128_t &l, const uint128_t &r)
Definition: uint128_t.h:38
bool operator>(const uint128_t &l, const uint128_t &r)
Definition: uint128_t.h:44
bool operator!=(const uint128_t &l, const uint128_t &r)
Definition: uint128_t.h:48