diff --git a/CHANGELOG b/CHANGELOG index 6e872be..c79b4a6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,41 @@ +Version 0.8.1 (2007.04.17): + * fixed: Big::PowFrac(..) didn't return a correct error code + (when 'this' was negative) + * added: Root(x; index) (and to the parser as well) + * added: macro: TTMATH_PRERELEASE_VER (can be either zero or one) + * added: UInt::MulInt(int, UInt::&) + * added: Big::MulUInt(uint) + * changed: Big::MulInt(sint) + * added: Big::ToUInt(uint &) + * changed: Big::ToInt(sint&) + * changed: Factorial() it uses Big::MulUInt() at the beginning + (faster now especially more on a 32bit platform) + * added: doxygen.cfg for generating a documentation from the doxygen + * changed: UInt::Rcl(uint c=0) and UInt::Rcr(uint c=0) into + UInt::Rcl2(uint bits, uint c) and UInt::Rcr2(uint bits, uint c) + now they can move more than one bit and they are only private + * fixed: UInt::Rcl(uint bits, uint c) and UInt::Rcr(uint bits, uint c) + didn't correctly return a carry if the 'bits' were equal + to 'value_size*TTMATH_BITS_PER_UINT' + * changed: UInt::Rcl(uint bits, uint c) and UInt::Rcr(uint bits, uint c) + into UInt::Rcl(uint bits, uint c=0) and + UInt::Rcr(uint bits, uint c=0) + they are faster now when the bits is greater than a half of + the TTMATH_BITS_PER_UINT + * changed: UInt::CompensationToLeft() it's faster now + * changed: more small changes where there were UInt::Rcl(uint c=0) and + UInt::Rcr(uint c=0) used + * changed: as the Big type uses UInt::Rcl() and UInt::Rcr() a lot then + it is much faster now (about 5-25%) + * added: ASinh(), ACosh(), ATanh() /ATgh()/, ACoth() /ACtgh()/ + and to the parser as well + * added: UInt::BitAnd(), UInt::BitOr(), UInt::BitXor(), UInt::BitNot(), + Big::BitAnd(), Big::BitOr(), Big::BitXor() + * added: to the parser: bitand(), bitor(), bitxor() + /band(), bor(), bxor()/ + * changed: the way of parsing operators in the mathematical parser + (the parser is not too much greedy now) + Version 0.8.0 (2007.03.28): * added: into the parser: SetFactorialMax() * added: DegToDeg(deg, min, sec), DegToRad(deg), DegToRad(deg, min, sec), diff --git a/ttmath/ttmathbig.h b/ttmath/ttmathbig.h index 7a6c47c..26f741b 100644 --- a/ttmath/ttmathbig.h +++ b/ttmath/ttmathbig.h @@ -549,7 +549,7 @@ public: exp_offset.Sub( ss2.exponent ); exp_offset.Abs(); - // abs(this) will be >= abs(ss2) + // (1) abs(this) will be >= abs(ss2) if( SmallerWithoutSignThan(ss2) ) { Big temp(ss2); @@ -567,11 +567,12 @@ public: else if( exp_offset < mantissa_size_in_bits ) { - // moving 'exp_offset' times + // (2) moving 'exp_offset' times ss2.mantissa.Rcr( exp_offset.ToInt(), 0 ); } else { + // (3) // exp_offset == mantissa_size_in_bits // we're rounding 'this' about one (up or down depending on a ss2 sign) ss2.mantissa.SetOne(); @@ -590,11 +591,12 @@ public: else { // values have different signs - if( mantissa.Sub(ss2.mantissa) ) - { - mantissa.Rcl(1,1); // maybe without this rcl and subone()? !!!! - c = exponent.SubOne(); - } + // there shouldn't be a carry here because + // (1) (2) and (3) guarantee that the mantissa of this + // is greater than the mantissa of the ss2 + uint c_temp = mantissa.Sub(ss2.mantissa); + + TTMATH_ASSERT( c_temp == 0 ) } c += Standardizing(); diff --git a/ttmath/ttmathparser.h b/ttmath/ttmathparser.h index 2a8f008..b72359a 100644 --- a/ttmath/ttmathparser.h +++ b/ttmath/ttmathparser.h @@ -1619,13 +1619,22 @@ void CreateMathematicalOperatorsTable() } -bool CanBeMathematicalOperator(unsigned char c) -{ - if( c=='|' || c=='&' || c=='!' || c=='=' || c=='<' || c=='>' || - c=='*' || c=='/' || c=='+' || c=='-' || c=='^' ) - return true; +/*! + returns true if 'str2' is the substring of str1 -return false; + e.g. + true when str1="test" and str2="te" +*/ +bool IsSubstring(const std::string & str1, const std::string & str2) +{ + if( str2.length() > str1.length() ) + return false; + + for(std::string::size_type i=0 ; ifirst, oper) ) + { + oper.erase( --oper.end() ); // we've got mininum one element - typename OperatorsTable::iterator iter = operators_table.find(oper); - - if( iter == operators_table.end() ) - Error( err_unknown_operator ); - - result.type = Item::mat_operator; - result.moperator.SetType( iter->second ); + if( iter_old != operators_table.end() && iter_old->first == oper ) + { + result.type = Item::mat_operator; + result.moperator.SetType( iter_old->second ); + break; + } + + Error( err_unknown_operator ); + } + + iter_old = iter_new; + } } @@ -1676,10 +1699,7 @@ int ReadOperator(Item & result) ++pstring; } else - if( CanBeMathematicalOperator(*pstring) ) ReadMathematicalOperator(result); - else - Error( err_unknown_character ); return 0; } diff --git a/ttmath/ttmathtypes.h b/ttmath/ttmathtypes.h index 2a38b7d..414170b 100644 --- a/ttmath/ttmathtypes.h +++ b/ttmath/ttmathtypes.h @@ -65,7 +65,7 @@ #define TTMATH_MAJOR_VER 0 #define TTMATH_MINOR_VER 8 #define TTMATH_REVISION_VER 1 -#define TTMATH_PRERELEASE_VER 1 +#define TTMATH_PRERELEASE_VER 0 /*!