correction for time control and precision

This commit is contained in:
hamidrezanorouzi 2022-10-04 11:58:03 +03:30
parent 9e955fa11e
commit b19e6a0333
3 changed files with 37 additions and 2 deletions

View File

@ -105,8 +105,7 @@ public:
word currentTimeWord() const
{
word ctw = real2Word( currentTime(), timePrecision());
return ctw;
return real2FixedStripZeros( currentTime(), timePrecision());;
}
int32 currentIter()const

View File

@ -72,6 +72,38 @@ pFlow::word pFlow::int322Word(const int32 & v)
return ss.str();
}
pFlow::word pFlow::removeDecimalZeros(const word& str)
{
auto dec = str.find('.');
if(dec == word::npos) return str;
auto len = str.size();
if(len == word::npos) return str;
auto firstZero = word::npos;
for(auto n=len-1; n>dec;n--)
{
if( str[n] == '0' )
{
firstZero = n;
}
else
{
break;
}
}
if(firstZero == dec+1) firstZero = dec;
return str.substr(0,firstZero);
}
pFlow::word pFlow::real2FixedStripZeros(const real & v, int32 numPrecision)
{
word strVal = real2Fixed(v, numPrecision);
return removeDecimalZeros(strVal);
}
pFlow::word pFlow::toUpper(const word & inStr)
{
word oStr(inStr);

View File

@ -57,6 +57,10 @@ word real2Fixed(const real & v, int32 numPrecision = 6);
word real2Word(const real & v, int32 numPrecision = 6);
word removeDecimalZeros(const word& str);
word real2FixedStripZeros(const real & v, int32 numPrecision = 6);
word int322Word(const int32 & v);