Skip to content
Browse files

Use double instead of float in meters.

  • Loading branch information...
1 parent d3b0a80 commit 74aff6f6385c0e42bc8001a390cfafea12693636 Tomi Tapper committed May 29, 2012
Showing with 20 additions and 20 deletions.
  1. +4 −4 bitfieldmeter.cc
  2. +3 −3 bitfieldmeter.h
  3. +3 −3 fieldmeter.cc
  4. +1 −1 fieldmeter.h
  5. +3 −3 fieldmeterdecay.cc
  6. +2 −2 fieldmeterdecay.h
  7. +2 −2 fieldmetergraph.cc
  8. +1 −1 fieldmetergraph.h
  9. +1 −1 linux/raidmeter.cc
View
8 bitfieldmeter.cc
@@ -91,7 +91,7 @@ void BitFieldMeter::SetUsedFormat ( const char * const fmt ) {
}
}
-void BitFieldMeter::setUsed (float val, float total)
+void BitFieldMeter::setUsed (double val, double total)
{
if (print_ == FLOAT)
used_ = val;
@@ -206,7 +206,7 @@ void BitFieldMeter::drawused( int manditory ){
}
else if (print_ == AUTOSCALE){
char scale;
- float scaled_used;
+ double scaled_used;
/* Unfortunately, we have to do our comparisons by 1000s (otherwise
* a value of 1020, which is smaller than 1K, could end up
* being printed as 1020, which is wider than what can fit) */
@@ -301,7 +301,7 @@ void BitFieldMeter::drawfields( int manditory ){
"will not be displayed.\n", name());
}
- twidth = (int) (((width_/2 - 3) * (float) fields_[i]) / total_);
+ twidth = (int) (((width_/2 - 3) * (double) fields_[i]) / total_);
// twidth = (int)((fields_[i] * width_) / total_);
if ( (i == numfields_ - 1) && ((x + twidth) != (x_ + width_)) )
twidth = width_ + x_ - x;
@@ -342,7 +342,7 @@ void BitFieldMeter::setNumFields(int n){
delete[] colors_;
delete[] lastvals_;
delete[] lastx_;
- fields_ = new float[numfields_];
+ fields_ = new double[numfields_];
colors_ = new unsigned long[numfields_];
lastvals_ = new int[numfields_];
lastx_ = new int[numfields_];
View
6 bitfieldmeter.h
@@ -29,7 +29,7 @@ class BitFieldMeter : public Meter {
void dousedlegends( int val ) { dousedlegends_ = val; }
void reset( void );
- void setUsed (float val, float total);
+ void setUsed (double val, double total);
void setBits(int startbit, unsigned char values);
void draw( void );
@@ -42,8 +42,8 @@ class BitFieldMeter : public Meter {
enum UsedType { INVALID_0, FLOAT, PERCENT, AUTOSCALE, INVALID_TAIL };
int numfields_;
- float *fields_;
- float total_, used_, lastused_;
+ double *fields_;
+ double total_, used_, lastused_;
int *lastvals_, *lastx_;
unsigned long *colors_;
unsigned long usedcolor_;
View
6 fieldmeter.cc
@@ -70,7 +70,7 @@ void FieldMeter::SetUsedFormat ( const char * const fmt ) {
}
}
-void FieldMeter::setUsed (float val, float total)
+void FieldMeter::setUsed (double val, double total)
{
if (print_ == FLOAT)
used_ = val;
@@ -180,7 +180,7 @@ void FieldMeter::drawused( int manditory ){
}
else if (print_ == AUTOSCALE){
char scale;
- float scaled_used;
+ double scaled_used;
/* Unfortunately, we have to do our comparisons by 1000s (otherwise
* a value of 1020, which is smaller than 1K, could end up
* being printed as 1020, which is wider than what can fit) */
@@ -260,7 +260,7 @@ void FieldMeter::drawfields( int manditory ){
"will not be displayed.\n", name());
}
- twidth = (int) ((width_ * (float) fields_[i]) / total_);
+ twidth = (int) ((width_ * (double) fields_[i]) / total_);
// twidth = (int)((fields_[i] * width_) / total_);
if ( (i == numfields_ - 1) && ((x + twidth) != (x_ + width_)) )
twidth = width_ + x_ - x;
View
2 fieldmeter.h
@@ -28,7 +28,7 @@ class FieldMeter : public Meter {
void used_obsolete( int val ) { print_ = PERCENT; used_ = val; }
void absolute_obsolete( float val ) { print_ = FLOAT; used_ = val; }
- void setUsed (float val, float total);
+ void setUsed (double val, double total);
void draw( void );
void checkevent( void );
void disableMeter ( void );
View
6 fieldmeterdecay.cc
@@ -38,8 +38,8 @@ FieldMeterDecay::FieldMeterDecay( XOSView *parent,
: FieldMeter (parent, numfields, title, legend, docaptions, dolegends,
dousedlegends)
{
- decay_ = new float[numfields];
- lastDecayval_ = new float[numfields];
+ decay_ = new double[numfields];
+ lastDecayval_ = new double[numfields];
for (int decayCtr = 0; decayCtr < numfields; decayCtr++) {
decay_[decayCtr] = 0.0;
lastDecayval_[decayCtr] = 0.0;
@@ -108,7 +108,7 @@ void FieldMeterDecay::drawfields( int manditory ){
decay_[i] = ALPHA*decay_[i] + (1-ALPHA)*(fields_[i]*1.0/total_);
// We want to round the widths, rather than truncate.
- twidth = (int) (0.5 + (width_ * (float) fields_[i]) / total_);
+ twidth = (int) (0.5 + (width_ * (double) fields_[i]) / total_);
decaytwidth = (int) (0.5 + width_ * decay_[i]);
if (decaytwidth < 0.0) {
std::cerr << "Error: FieldMeterDecay " << name() << ": decaytwidth of ";
View
4 fieldmeterdecay.h
@@ -31,8 +31,8 @@ class FieldMeterDecay : public FieldMeter {
protected:
int dodecay_;
int firsttime_; // Used to set up decaying fields right the first time.
- float *decay_;
- float *lastDecayval_;
+ double *decay_;
+ double *lastDecayval_;
private:
};
View
4 fieldmetergraph.cc
@@ -73,7 +73,7 @@ void FieldMeterGraph::drawfields( int manditory )
{
if( numfields_ > 0 && graphNumCols_ > 0 )
{
- heightfield_ = new float [numfields_*graphNumCols_];
+ heightfield_ = new double [numfields_*graphNumCols_];
for( i = 0; i < graphNumCols_; i++ )
{
@@ -104,7 +104,7 @@ void FieldMeterGraph::drawfields( int manditory )
// get current values to be plotted
for( i = 0; i < numfields_; i++ )
{
- float a = fields_[i] / total_;
+ double a = fields_[i] / total_;
if( a <= 0.0 )
a = 0.0;
if( a >= 1.0 )
View
2 fieldmetergraph.h
@@ -36,7 +36,7 @@ class FieldMeterGraph : public FieldMeterDecay {
/* There's some sort of corruption going on -- we can't have
* variables after the heightfield_ below, otherwise they get
* corrupted??? */
- float *heightfield_;
+ double *heightfield_;
private:
void drawBar( int i );
};
View
2 linux/raidmeter.cc
@@ -40,7 +40,7 @@ void RAIDMeter::checkevent( void ){
bits_[i] = (working_map[i]=='+');
}
fields_[0]=100.0;
- sscanf(resync_state, "resync=%f", &fields_[0] );
+ sscanf(resync_state, "resync=%lf", &fields_[0] );
fields_[1] = total_ - fields_[1];
if(fields_[0]<100.0){
setfieldcolor(0,doneColor_);

0 comments on commit 74aff6f

Please sign in to comment.
Something went wrong with that request. Please try again.