|
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
|
2 /* |
|
3 * Copyright (c) 2006 INRIA |
|
4 * All rights reserved. |
|
5 * |
|
6 * This program is free software; you can redistribute it and/or modify |
|
7 * it under the terms of the GNU General Public License version 2 as |
|
8 * published by the Free Software Foundation; |
|
9 * |
|
10 * This program 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 |
|
13 * GNU General Public License for more details. |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License |
|
16 * along with this program; if not, write to the Free Software |
|
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 * |
|
19 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
|
20 */ |
|
21 #ifndef HIGH_PRECISION_128_H |
|
22 #define HIGH_PRECISION_128_H |
|
23 |
|
24 #include <stdint.h> |
|
25 |
|
26 namespace ns3 { |
|
27 |
|
28 /** |
|
29 * This should be a high-precision 128bit integer version of |
|
30 * HighPrecision class. It should also be able to report |
|
31 * overflow and underflow. |
|
32 */ |
|
33 class HighPrecision |
|
34 { |
|
35 public: |
|
36 HighPrecision (); |
|
37 HighPrecision (int64_t high, int64_t low); |
|
38 HighPrecision (double value); |
|
39 |
|
40 int64_t GetHigh (void) const; |
|
41 int64_t GetLow (void) const; |
|
42 double GetDouble (void) const; |
|
43 bool Add (HighPrecision const &o); |
|
44 bool Sub (HighPrecision const &o); |
|
45 bool Mul (HighPrecision const &o); |
|
46 bool Div (HighPrecision const &o); |
|
47 |
|
48 int Compare (HighPrecision const &o) const; |
|
49 static HighPrecision Zero (void); |
|
50 private: |
|
51 int64_t m_high; |
|
52 int64_t m_low; |
|
53 }; |
|
54 |
|
55 }; // namespace ns3 |
|
56 |
|
57 #endif /* HIGH_PRECISION_128_H */ |