diff --git a/ttmath/ttmathbig.h b/ttmath/ttmathbig.h index 12eabc4..b65e06a 100644 --- a/ttmath/ttmathbig.h +++ b/ttmath/ttmathbig.h @@ -47,7 +47,10 @@ #include "ttmaththreads.h" #include + +#ifdef TTMATH_MULTITHREADS #include +#endif namespace ttmath { @@ -2980,7 +2983,40 @@ private: } +#ifndef TTMATH_MULTITHREADS + /*! + this method calculates the logarithm of 'base' + it's used in single thread environment + */ + uint ToString_LogBase(uint base, Big & result) + { + TTMATH_ASSERT( base>=2 && base<=16 ) + + // this guardians are initialized before the program runs (static POD types) + static int guardians[15] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + static Big log_history[15]; + uint index = base - 2; + uint c = 0; + + if( guardians[index] == 0 ) + { + Big base_(base); + c += log_history[index].Ln(base_); + guardians[index] = 1; + } + + result = log_history[index]; + + return (c==0)? 0 : 1; + } + +#else + + /*! + this method calculates the logarithm of 'base' + it's used in multi-thread environment + */ uint ToString_LogBase(uint base, Big & result) { TTMATH_ASSERT( base>=2 && base<=16 ) @@ -3027,6 +3063,7 @@ private: return (c==0)? 0 : 1; } +#endif /*! an auxiliary method for converting into the string (private)