A Discrete-Event Network Simulator
API
int64x64.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010 INRIA
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  */
18 
19 #ifndef INT64X64_H
20 #define INT64X64_H
21 
22 #include "ns3/core-config.h"
23 
24 // Order is important here, as it determines which implementation
25 // will generate doxygen API docs. This order mimics the
26 // selection logic in CMakeLists.txt, so we generate docs from the
27 // implementation actually chosen by the configuration.
28 #if defined(INT64X64_USE_128) && !defined(PYTHON_SCAN)
29 #include "int64x64-128.h"
30 #elif defined(INT64X64_USE_CAIRO) && !defined(PYTHON_SCAN)
31 #include "int64x64-cairo.h"
32 #elif defined(INT64X64_USE_DOUBLE) || defined(PYTHON_SCAN)
33 #include "int64x64-double.h"
34 #endif
35 
36 #include <iostream>
37 
44 namespace ns3
45 {
46 
87 inline int64x64_t
88 operator+(const int64x64_t& lhs, const int64x64_t& rhs)
89 {
90  int64x64_t tmp = lhs;
91  tmp += rhs;
92  return tmp;
93 }
94 
102 inline int64x64_t
103 operator-(const int64x64_t& lhs, const int64x64_t& rhs)
104 {
105  int64x64_t tmp = lhs;
106  tmp -= rhs;
107  return tmp;
108 }
109 
117 inline int64x64_t
118 operator*(const int64x64_t& lhs, const int64x64_t& rhs)
119 {
120  int64x64_t tmp = lhs;
121  tmp *= rhs;
122  return tmp;
123 }
124 
132 inline int64x64_t
133 operator/(const int64x64_t& lhs, const int64x64_t& rhs)
134 {
135  int64x64_t tmp = lhs;
136  tmp /= rhs;
137  return tmp;
138 }
139 
147 inline bool
148 operator!=(const int64x64_t& lhs, const int64x64_t& rhs)
149 {
150  return !(lhs == rhs);
151 }
152 
160 inline bool
161 operator<=(const int64x64_t& lhs, const int64x64_t& rhs)
162 {
163  return !(lhs > rhs);
164 }
165 
173 inline bool
174 operator>=(const int64x64_t& lhs, const int64x64_t& rhs)
175 {
176  return !(lhs < rhs);
177 }
178 
197 std::ostream& operator<<(std::ostream& os, const int64x64_t& value);
206 std::istream& operator>>(std::istream& is, int64x64_t& value);
207 
214 inline int64x64_t
215 Abs(const int64x64_t& value)
216 {
217  return (value < 0) ? -value : value;
218 }
219 
228 inline int64x64_t
229 Min(const int64x64_t& a, const int64x64_t& b)
230 {
231  return (a < b) ? a : b;
232 }
233 
242 inline int64x64_t
243 Max(const int64x64_t& a, const int64x64_t& b)
244 {
245  return (a > b) ? a : b;
246 }
247 
248 } // namespace ns3
249 
250 #endif /* INT64X64_H */
High precision numerical type, implementing Q64.64 fixed precision.
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
Definition: int64x64.h:243
int64x64_t operator/(const int64x64_t &lhs, const int64x64_t &rhs)
Division operator.
Definition: int64x64.h:133
bool operator>=(const int64x64_t &lhs, const int64x64_t &rhs)
Greater or equal operator.
Definition: int64x64.h:174
bool operator<=(const int64x64_t &lhs, const int64x64_t &rhs)
Less or equal operator.
Definition: int64x64.h:161
int64x64_t operator-(const int64x64_t &lhs, const int64x64_t &rhs)
Subtraction operator.
Definition: int64x64.h:103
int64x64_t operator+(const int64x64_t &lhs, const int64x64_t &rhs)
Addition operator.
Definition: int64x64.h:88
int64x64_t Abs(const int64x64_t &value)
Absolute value.
Definition: int64x64.h:215
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
Definition: int64x64.h:229
int64x64_t operator*(const int64x64_t &lhs, const int64x64_t &rhs)
Multiplication operator.
Definition: int64x64.h:118
Declaration of the ns3::int64x64_t type using the Cairo implementation.
Declaration and implementation of the ns3::int64x64_t type using the double type.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool operator!=(Callback< R, Args... > a, Callback< R, Args... > b)
Inequality test.
Definition: callback.h:678
std::istream & operator>>(std::istream &is, Angles &a)
Definition: angles.cc:183
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:159