Assigning a double value, stored in variable A to a variable B alters it's value as soon the value gets below 0.000001. I've read about about problems with 80 Bit FPU's, but in this case, that problem shouldn't occur, as I'm only assigning a value, not calculating something with it. Here is some piece of example code:
double elapsed = _sinceCreation.elapsed();
if ( benchmark->minTime > elapsed ) {
benchmark->minTime = elapsed;
}
benchmark->minTime
should equal _sinceCreation.elapsed()
, but it surprisingly doesn't! What could be the reason for this? And how can I fix this behavior?
EDIT:
To complete my explanation, here is the method where it behaves weird (inclusive testing output to verify equality):
double elapsed = _sinceCreation.elapsed();
if ( _benchmarkMap.find(benchmark->methodName) == _benchmarkMap.end() ) {
_benchmarkMap[benchmark->methodName] = benchmark;
}
if ( benchmark->times.size() >= _benchmarkLimitPerMethod ||
benchmark->times.size() >= benchmark->times.max_size() ) {
benchmark->times.pop_front();
benchmark->maxSizeReached = true;
}
benchmark->times.push_back( elapsed );
if ( benchmark->minTime > elapsed ) {
std::cout << printToString("before min time: {0:0.15f} elapsed: {0:0.15f}", benchmark->minTime, elapsed) << std::endl;
benchmark->minTime = elapsed;
std::cout << printToString("after min time: {0:0.15f} elapsed: {0:0.15f}", benchmark->minTime, elapsed) << std::endl;
}
if ( benchmark->maxTime < elapsed )
benchmark->maxTime = elapsed;
_sinceCreation
is a timestamp class, returning double secs since last setCurrentTime()
and printToString()
is a own wrapper for fmtlib.