X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=src%2Fparanoidnumber.h;h=3a38286ae706d03bd9babe981cb02c235458bd8b;hb=b29310a04a51cd7d39d0858e2dec8a75c15cf097;hp=47dbdc97e2a61d7c76da2c6bc9a4605b113f2148;hpb=f8b8daf1828b8a8028b9344dd0feca1b8d9e859a;p=ipdf%2Fcode.git diff --git a/src/paranoidnumber.h b/src/paranoidnumber.h index 47dbdc9..3a38286 100644 --- a/src/paranoidnumber.h +++ b/src/paranoidnumber.h @@ -12,19 +12,21 @@ #include // it's going to be ok #include -#define PARANOID_DIGIT_T double // we could theoretically replace this with a template +#define PARANOID_DIGIT_T float // we could theoretically replace this with a template // but let's not do that... //#define PARANOID_CACHE_RESULTS //#define PARANOID_USE_ARENA -#define PARANOID_SIZE_LIMIT 1 +#define PARANOID_SIZE_LIMIT 10 // Define to compare all ops against double ops and check within epsilon -#define PARANOID_COMPARE_EPSILON 1e-6 +//#define PARANOID_COMPARE_EPSILON 1e- +#ifdef PARANOID_COMPARE_EPSILON #define CompareForSanity(...) ParanoidNumber::CompareForSanityEx(__func__, __FILE__, __LINE__, __VA_ARGS__) +#endif namespace IPDF { @@ -87,7 +89,7 @@ namespace IPDF ParanoidNumber(PARANOID_DIGIT_T value=0) : m_value(value), m_next() { #ifdef PARANOID_SIZE_LIMIT - m_size = 0; + m_size = 1; #endif #ifdef PARANOID_CACHE_RESULTS m_cached_result = value; @@ -233,6 +235,7 @@ namespace IPDF std::string Str() const; + #ifdef PARANOID_COMPARE_EPSILON 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()) @@ -244,7 +247,7 @@ namespace IPDF Fatal("This: %.30lf vs Expected: %.30lf", Digit(), compare); } } - + #endif std::string PStr() const;