From: Sam Moore Date: Wed, 24 Sep 2014 11:48:20 +0000 (+0800) Subject: Doomed to failure X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=commitdiff_plain;h=f8b8daf1828b8a8028b9344dd0feca1b8d9e859a Doomed to failure BLasdfuywetraefrdg --- diff --git a/src/paranoidnumber.cpp b/src/paranoidnumber.cpp index 40071e1..efae860 100644 --- a/src/paranoidnumber.cpp +++ b/src/paranoidnumber.cpp @@ -432,14 +432,13 @@ ParanoidNumber * ParanoidNumber::OperationTerm(ParanoidNumber * b, Optype op, Pa #ifdef PARANOID_SIZE_LIMIT if (m_size >= PARANOID_SIZE_LIMIT) { + this->operator=(this->Digit()); if (op == ADD) - { - m_value += b->Digit() / GetFactors(); - } + m_value += b->Digit(); else - { - m_value -= b->Digit() / GetFactors(); - } + m_value -= b->Digit(); + m_size = 0; + Debug("Cut off %p", this); return b; } //Debug("At size limit %d", m_size); @@ -567,15 +566,14 @@ ParanoidNumber * ParanoidNumber::OperationFactor(ParanoidNumber * b, Optype op, #ifdef PARANOID_SIZE_LIMIT if (m_size >= PARANOID_SIZE_LIMIT) { + this->operator=(this->Digit()); if (op == MULTIPLY) m_value *= b->Digit(); else m_value /= b->Digit(); - - for (auto n : m_next[ADD]) - delete n->OperationFactor(new ParanoidNumber(*b), op); - for (auto n : m_next[SUBTRACT]) - delete n->OperationFactor(new ParanoidNumber(*b), op); + m_size = 0; + + Debug("Cut off %p", this); return b; } diff --git a/src/paranoidnumber.h b/src/paranoidnumber.h index e57d00c..47dbdc9 100644 --- a/src/paranoidnumber.h +++ b/src/paranoidnumber.h @@ -19,7 +19,7 @@ //#define PARANOID_CACHE_RESULTS //#define PARANOID_USE_ARENA -#define PARANOID_SIZE_LIMIT 0 +#define PARANOID_SIZE_LIMIT 1 // Define to compare all ops against double ops and check within epsilon @@ -235,6 +235,8 @@ namespace IPDF inline void CompareForSanityEx(const char * func, const char * file, int line, const digit_t & compare, const digit_t & arg, const digit_t & eps = PARANOID_COMPARE_EPSILON) { + if (!SanityCheck()) + Fatal("This is insane!"); if (fabs(Digit() - compare) > eps) { Error("Called via %s(%lf) (%s:%d)", func, arg, file, line); diff --git a/src/single b/src/single new file mode 100755 index 0000000..fb36604 Binary files /dev/null and b/src/single differ