m_size = 1;
#endif
#ifdef PARANOID_CACHE_RESULTS
- m_cached_result = NAN;
+ m_cache_valid = false;
#endif
int dp = 0;
#endif
m_value = a.m_value;
- #ifdef PARANOID_CACHE_RESULT
+ #ifdef PARANOID_CACHE_RESULTS
m_cached_result = a.m_cached_result;
+ m_cache_valid = a.m_cache_valid;
#endif
for (int i = 0; i < NOP; ++i)
{
m_next[i].clear();
}
m_value = a;
- #ifdef PARANOID_CACHE_RESULT
+ #ifdef PARANOID_CACHE_RESULTS
m_cached_result = a;
+ m_cache_valid = true;
#endif
#ifdef PARANOID_COMPARE_EPSILON
{
////assert(b->SanityCheck());
#ifdef PARANOID_CACHE_RESULTS
- m_cached_result = NAN;
+ m_cache_valid = false;
#endif
#ifdef PARANOID_SIZE_LIMIT
if (m_size + b->m_size >= PARANOID_SIZE_LIMIT)
else
m_value -= b->Digit();
m_size = 1;
- //Debug("Cut off %p", this);
+ #ifdef PARANOID_CACHE_RESULTS
+ m_cached_result = m_value;
+ m_cache_valid = true;
+ #endif
return b;
}
//Debug("At size limit %d", m_size);
ParanoidNumber * ParanoidNumber::OperationFactor(ParanoidNumber * b, Optype op, ParanoidNumber ** merge_point, Optype * merge_op)
{
#ifdef PARANOID_CACHE_RESULTS
- m_cached_result = NAN;
+ m_cache_valid = false;
#endif
#ifdef PARANOID_SIZE_LIMIT
if (m_size + b->m_size >= PARANOID_SIZE_LIMIT)
else
m_value /= b->Digit();
m_size = 1;
-
+ #ifdef PARANOID_CACHE_RESULTS
+ m_cached_result = m_value;
+ m_cache_valid = true;
+ #endif
//Debug("Cut off %p", this);
return b;
// Get around the absurd requirement that const correctness be observed.
#ifdef PARANOID_CACHE_RESULTS
+ if (m_cache_valid) // le sigh ambiguous function compiler warnings
+ return m_cached_result;
+
digit_t & result = ((ParanoidNumber*)(this))->m_cached_result;
- if (!isnan(float(result))) // le sigh ambiguous function compiler warnings
- return result;
#else
digit_t result;
#endif
result += add->Digit();
for (auto sub : m_next[SUBTRACT])
result -= sub->Digit();
+
+ #ifdef PARANOID_CACHE_RESULTS
+ ((ParanoidNumber*)(this))->m_cache_valid = true;
+ #endif
return result;
}
{
swap(m_next[ADD], m_next[SUBTRACT]);
m_value = -m_value;
+ #ifdef PARANOID_CACHE_RESULTS
+ m_cached_result = -m_cached_result;
+ #endif
}
#ifdef PARANOID_USE_ARENA