00001 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright (c) 2006 INRIA 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation; 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> 00019 */ 00020 #include "high-precision-double.h" 00021 00022 #include <cmath> 00023 #include "ns3/assert.h" 00024 00025 00026 namespace ns3 { 00027 00028 HighPrecision::HighPrecision () 00029 : m_value (0.0) 00030 {} 00031 00032 HighPrecision::HighPrecision (int64_t value, bool dummy) 00033 : m_value ((double)value) 00034 {} 00035 00036 HighPrecision::HighPrecision (double value) 00037 : m_value (value) 00038 {} 00039 00040 int64_t 00041 HighPrecision::GetInteger (void) const 00042 { 00043 return (int64_t)floor (m_value); 00044 } 00045 00046 double 00047 HighPrecision::GetDouble (void) const 00048 { 00049 return m_value; 00050 } 00051 bool 00052 HighPrecision::Add (HighPrecision const &o) 00053 { 00054 m_value += o.m_value; 00055 return false; 00056 } 00057 bool 00058 HighPrecision::Sub (HighPrecision const &o) 00059 { 00060 m_value -= o.m_value; 00061 return false; 00062 } 00063 bool 00064 HighPrecision::Mul (HighPrecision const &o) 00065 { 00066 m_value *= o.m_value; 00067 return false; 00068 } 00069 bool 00070 HighPrecision::Div (HighPrecision const &o) 00071 { 00072 m_value /= o.m_value; 00073 return false; 00074 } 00075 int 00076 HighPrecision::Compare (HighPrecision const &o) const 00077 { 00078 return 0; 00079 } 00080 HighPrecision 00081 HighPrecision::Zero (void) 00082 { 00083 return HighPrecision (0,0); 00084 } 00085 00086 }; // namespace ns3