A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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
44namespace ns3
45{
46
87inline int64x64_t
88operator+(const int64x64_t& lhs, const int64x64_t& rhs)
89{
90 int64x64_t tmp = lhs;
91 tmp += rhs;
92 return tmp;
93}
94
102inline int64x64_t
103operator-(const int64x64_t& lhs, const int64x64_t& rhs)
104{
105 int64x64_t tmp = lhs;
106 tmp -= rhs;
107 return tmp;
108}
109
117inline int64x64_t
118operator*(const int64x64_t& lhs, const int64x64_t& rhs)
119{
120 int64x64_t tmp = lhs;
121 tmp *= rhs;
122 return tmp;
123}
124
132inline int64x64_t
133operator/(const int64x64_t& lhs, const int64x64_t& rhs)
134{
135 int64x64_t tmp = lhs;
136 tmp /= rhs;
137 return tmp;
138}
139
147inline bool
148operator!=(const int64x64_t& lhs, const int64x64_t& rhs)
149{
150 return !(lhs == rhs);
151}
152
160inline bool
161operator<=(const int64x64_t& lhs, const int64x64_t& rhs)
162{
163 return !(lhs > rhs);
164}
165
173inline bool
174operator>=(const int64x64_t& lhs, const int64x64_t& rhs)
175{
176 return !(lhs < rhs);
177}
178
197std::ostream& operator<<(std::ostream& os, const int64x64_t& value);
206std::istream& operator>>(std::istream& is, int64x64_t& value);
207
214inline int64x64_t
215Abs(const int64x64_t& value)
216{
217 return (value < 0) ? -value : value;
218}
219
228inline int64x64_t
229Min(const int64x64_t& a, const int64x64_t& b)
230{
231 return (a < b) ? a : b;
232}
233
242inline int64x64_t
243Max(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 */
#define Max(a, b)
#define Min(a, b)
High precision numerical type, implementing Q64.64 fixed precision.
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 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:676
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:129
std::istream & operator>>(std::istream &is, Angles &a)
Definition: angles.cc:153