Simpatico  v1.10
Dbl.h
1 #ifndef UTIL_DBL_H
2 #define UTIL_DBL_H
3 
4 /*
5 * Util Package - C++ Utilities for Scientific Computation
6 *
7 * Copyright 2010 - 2017, The Regents of the University of Minnesota
8 * Distributed under the terms of the GNU General Public License.
9 */
10 
11 #include <iostream>
12 
13 namespace Util
14 {
15 
39  class Dbl
40  {
41 
42  public:
43 
45 
46 
50  Dbl();
51 
55  explicit Dbl(double value);
56 
60  Dbl(double value, int width);
61 
65  Dbl(double value, int width, int precision, bool isFixed = false);
66 
68 
70 
74  void setValue(double value);
75 
79  void setWidth(int width);
80 
84  void setPrecision(int precision);
85 
87 
89 
93  double value();
94 
98  int width();
99 
103  int precision();
104 
106 
107  private:
108 
110  double value_;
111 
113  int width_;
114 
116  int precision_;
117 
119  bool isFixed_;
120 
121  //friends:
122 
123  friend std::istream& operator>>(std::istream& in, Dbl &object);
124  friend std::ostream& operator<<(std::ostream& out, const Dbl &object);
125 
126  };
127 
135  std::istream& operator>>(std::istream& in, Dbl &object);
136 
144  std::ostream& operator<<(std::ostream& out, const Dbl &object);
145 
146 }
147 #endif
Dbl()
Default constructor.
Definition: Dbl.cpp:17
Wrapper for a double precision number, for formatted ostream output.
Definition: Dbl.h:39
int precision()
Get floating point precision.
Definition: Dbl.cpp:63
double value()
Get value of associated double.
Definition: Dbl.cpp:57
void setWidth(int width)
Set output field width.
Definition: Dbl.cpp:51
Utility classes for scientific computation.
Definition: accumulators.mod:1
void setPrecision(int precision)
Set output floating point precision.
Definition: Dbl.cpp:54
void setValue(double value)
Set value of associated double.
Definition: Dbl.cpp:48
int width()
Get field width.
Definition: Dbl.cpp:60
friend std::ostream & operator<<(std::ostream &out, const Dbl &object)
Output stream inserter for an Dbl object.
Definition: Dbl.cpp:86
friend std::istream & operator>>(std::istream &in, Dbl &object)
Input stream extractor for an Dbl object.
Definition: Dbl.cpp:73