#include <cassert> // it's going to be ok
#include <set>
-#define PARANOID_DIGIT_T float // we could theoretically replace this with a template
+#define PARANOID_DIGIT_T double // 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 10
+#define PARANOID_SIZE_LIMIT 4
// Define to compare all ops against double ops and check within epsilon
-//#define PARANOID_COMPARE_EPSILON 1e-
+//#define PARANOID_COMPARE_EPSILON 1e-6
#ifdef PARANOID_COMPARE_EPSILON
#define CompareForSanity(...) ParanoidNumber::CompareForSanityEx(__func__, __FILE__, __LINE__, __VA_ARGS__)
#endif
#endif
#ifdef PARANOID_CACHE_RESULTS
m_cached_result = value;
+ m_cache_valid = true;
#endif
}
#endif
#ifdef PARANOID_CACHE_RESULTS
m_cached_result = cpy.m_cached_result;
+ m_cache_valid = cpy.m_cache_valid;
#endif
for (int i = 0; i < NOP; ++i)
{
// Like this one. It isn't const.
double ToDouble() const {return (double)Digit();}
+ operator double() const {return ToDouble();}
+
// This one is probably const.
bool Floating() const
{
digit_t m_value;
#ifdef PARANOID_CACHE_RESULTS
digit_t m_cached_result;
+ bool m_cache_valid;
#endif
std::vector<ParanoidNumber*> m_next[4];
#ifdef PARANOID_SIZE_LIMIT
class Arena
{
public:
- Arena(int64_t block_size = 10000000);
+ Arena(int64_t block_size = 10000);
~Arena();
void * allocate(size_t bytes);
T ParanoidNumber::Convert() const
{
#ifdef PARANOID_CACHE_RESULTS
- if (!isnan((float(m_cached_result))))
+ if (m_cache_valid)
return (T)m_cached_result;
#endif
T value(m_value);
+
+
}
#endif //_PARANOIDNUMBER_H