diff --git a/CHANGELOG b/CHANGELOG index e0a02d0..ce27724 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,16 @@ +Version 0.8.6 prerelease (2009.10.07): + * fixed: UInt::SetBitInWord(uint & value, uint bit) set 1 if the bit was + equal 1 (should be set 2) + this affected only no-asm parts - when macro TTMATH_NOASM was defined + * fixed: UInt::MulInt(uint ss2) + there was a buffer overflow when value_size was equal 1 + * fixed: UInt::AddVector() and UInt::SubVector() didn't want to compile + when macro TTMATH_NOASM was defined + * fixed: Big::operator>> didn't correctly recognize values in scientific mode (with 'e' character) + * fixed: Int::FromString(const tt_string & s, uint b = 10) + didn't use 'b' (always was '10') + + Version 0.8.5 (2009.06.16): * fixed: Big::Mod(x) didn't correctly return a carry and the result was sometimes very big (even greater than x) diff --git a/ttmath/ttmathbig.h b/ttmath/ttmathbig.h index 6c909ec..fc0760c 100644 --- a/ttmath/ttmathbig.h +++ b/ttmath/ttmathbig.h @@ -4160,9 +4160,11 @@ public: { std::string ss; - // 'char' for operator>> - unsigned char z; + // char for operator>> + char z, old_z; bool was_comma = false; + bool was_e = false; + // operator>> omits white characters if they're set for ommiting s >> z; @@ -4172,25 +4174,44 @@ public: ss += z; s >> z; // we're reading a next character (white characters can be ommited) } + + old_z = 0; // we're reading only digits (base=10) and only one comma operator - for( ; s.good() ; z=s.get() ) + for( ; s.good() ; z=static_cast(s.get()) ) { if( z == TTMATH_COMMA_CHARACTER_1 || ( z == TTMATH_COMMA_CHARACTER_2 && TTMATH_COMMA_CHARACTER_2 != 0 ) ) { - if( was_comma ) - // second comma operator + if( was_comma || was_e ) + // second comma operator or comma operator after 'e' character break; was_comma = true; } else + if( z == 'e' || z == 'E' ) + { + if( was_e ) + // second 'e' character + break; + + was_e = true; + } + else + if( z == '+' || z == '-' ) + { + if( old_z != 'e' && old_z != 'E' ) + // '+' or '-' is allowed only after 'e' character + break; + } + else if( UInt::CharToDigit(z, 10) < 0 ) break; - ss += z; + ss += z; + old_z = z; } // we're leaving the last read character diff --git a/ttmath/ttmathint.h b/ttmath/ttmathint.h index 71231ca..fcbbcfc 100644 --- a/ttmath/ttmathint.h +++ b/ttmath/ttmathint.h @@ -963,7 +963,7 @@ public: */ uint FromString(const std::string & s, uint b = 10) { - return FromString( s.c_str() ); + return FromString( s.c_str(), b ); } diff --git a/ttmath/ttmathtypes.h b/ttmath/ttmathtypes.h index a27f58f..7b82cce 100644 --- a/ttmath/ttmathtypes.h +++ b/ttmath/ttmathtypes.h @@ -64,8 +64,8 @@ */ #define TTMATH_MAJOR_VER 0 #define TTMATH_MINOR_VER 8 -#define TTMATH_REVISION_VER 5 -#define TTMATH_PRERELEASE_VER 0 +#define TTMATH_REVISION_VER 6 +#define TTMATH_PRERELEASE_VER 1 /*! diff --git a/ttmath/ttmathuint.h b/ttmath/ttmathuint.h index 2605cb5..06a408b 100644 --- a/ttmath/ttmathuint.h +++ b/ttmath/ttmathuint.h @@ -768,8 +768,7 @@ public: { MulTwoWords(u.table[x1], ss2, &r2, &r1 ); - - if( x1 <= value_size - 2 ) + if( value_size>1 && x1<=value_size-2 ) { if( AddTwoInts(r2,r1,x1) ) return 1; diff --git a/ttmath/ttmathuint_noasm.h b/ttmath/ttmathuint_noasm.h index c301fc5..636e582 100644 --- a/ttmath/ttmathuint_noasm.h +++ b/ttmath/ttmathuint_noasm.h @@ -224,7 +224,7 @@ namespace ttmath for( ; i 1 ) + if( bit > 0 ) mask = mask << bit; uint last = value & mask;