Add precision in the output of the eoValueParam.h

This commit is contained in:
verel 2014-11-09 15:17:41 +01:00
commit eb8f1e99a9
4 changed files with 19 additions and 3 deletions

View file

@ -67,13 +67,12 @@ eoMonitor& eoFileMonitor::operator()(void)
printHeader();
firstcall = false;
}
return operator()(os);
}
eoMonitor& eoFileMonitor::operator()(std::ostream& os)
{
iterator it = vec.begin();
os << (*it)->getValue();

View file

@ -96,6 +96,7 @@ public :
virtual void printHeader(std::ostream& os);
virtual std::string getFileName() { return filename;}
private :
@ -116,6 +117,7 @@ private :
//! erase the entire file prior to writing in it (mode eos_base::
bool overwrite;
};
#endif

View file

@ -167,6 +167,8 @@ public :
repValue(_defaultValue)
{
eoParam::defValue(getValue());
// default precision
numOfDigits = std::cout.precision();
}
/** Get a reference on the parameter value
@ -203,6 +205,7 @@ public :
std::string getValue(void) const
{
std::ostringstream os;
os.precision(numOfDigits);
os << repValue;
return os.str();
}
@ -227,9 +230,21 @@ public :
is >> repValue;
}
/**
set the precision of the output
@param _numOfDigits the precision of the output
*/
void setPrecision(unsigned _numOfDigits) {
numOfDigits = _numOfDigits;
}
protected:
ValueType repValue;
//! precision of the output
unsigned numOfDigits;
};
/*

View file

@ -162,7 +162,7 @@ private:
// true if the move is accepted
bool isAccept ;
// if true the HC stop when to improving solution is found
// if true : the HC stop when no improving solution is found
// if false : never stop, always continue (external continuator)
bool stop ;
};