Some fixes from trunk:

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<value_size>::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')


git-svn-id: svn://ttmath.org/publicrep/ttmath/branches/0.8.x@204 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2009-10-07 17:33:03 +00:00
parent b80f73f16b
commit 5ef27bdbd0
6 changed files with 47 additions and 14 deletions

View File

@ -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<value_size>::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): Version 0.8.5 (2009.06.16):
* fixed: Big::Mod(x) didn't correctly return a carry * fixed: Big::Mod(x) didn't correctly return a carry
and the result was sometimes very big (even greater than x) and the result was sometimes very big (even greater than x)

View File

@ -4160,9 +4160,11 @@ public:
{ {
std::string ss; std::string ss;
// 'char' for operator>> // char for operator>>
unsigned char z; char z, old_z;
bool was_comma = false; bool was_comma = false;
bool was_e = false;
// operator>> omits white characters if they're set for ommiting // operator>> omits white characters if they're set for ommiting
s >> z; s >> z;
@ -4172,25 +4174,44 @@ public:
ss += z; ss += z;
s >> z; // we're reading a next character (white characters can be ommited) 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 // we're reading only digits (base=10) and only one comma operator
for( ; s.good() ; z=s.get() ) for( ; s.good() ; z=static_cast<char>(s.get()) )
{ {
if( z == TTMATH_COMMA_CHARACTER_1 || if( z == TTMATH_COMMA_CHARACTER_1 ||
( z == TTMATH_COMMA_CHARACTER_2 && TTMATH_COMMA_CHARACTER_2 != 0 ) ) ( z == TTMATH_COMMA_CHARACTER_2 && TTMATH_COMMA_CHARACTER_2 != 0 ) )
{ {
if( was_comma ) if( was_comma || was_e )
// second comma operator // second comma operator or comma operator after 'e' character
break; break;
was_comma = true; was_comma = true;
} }
else 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<man>::CharToDigit(z, 10) < 0 ) if( UInt<man>::CharToDigit(z, 10) < 0 )
break; break;
ss += z; ss += z;
old_z = z;
} }
// we're leaving the last read character // we're leaving the last read character

View File

@ -963,7 +963,7 @@ public:
*/ */
uint FromString(const std::string & s, uint b = 10) uint FromString(const std::string & s, uint b = 10)
{ {
return FromString( s.c_str() ); return FromString( s.c_str(), b );
} }

View File

@ -64,8 +64,8 @@
*/ */
#define TTMATH_MAJOR_VER 0 #define TTMATH_MAJOR_VER 0
#define TTMATH_MINOR_VER 8 #define TTMATH_MINOR_VER 8
#define TTMATH_REVISION_VER 5 #define TTMATH_REVISION_VER 6
#define TTMATH_PRERELEASE_VER 0 #define TTMATH_PRERELEASE_VER 1
/*! /*!

View File

@ -768,8 +768,7 @@ public:
{ {
MulTwoWords(u.table[x1], ss2, &r2, &r1 ); MulTwoWords(u.table[x1], ss2, &r2, &r1 );
if( value_size>1 && x1<=value_size-2 )
if( x1 <= value_size - 2 )
{ {
if( AddTwoInts(r2,r1,x1) ) if( AddTwoInts(r2,r1,x1) )
return 1; return 1;

View File

@ -224,7 +224,7 @@ namespace ttmath
for( ; i<ss1_size ; ++i) for( ; i<ss1_size ; ++i)
c = AddTwoWords(ss1[i], 0, c, &result[i]); c = AddTwoWords(ss1[i], 0, c, &result[i]);
TTMATH_LOG("UInt::AddVector") //TTMATH_LOG("UInt::AddVector")
return c; return c;
} }
@ -351,7 +351,7 @@ namespace ttmath
for( ; i<ss1_size ; ++i) for( ; i<ss1_size ; ++i)
c = SubTwoWords(ss1[i], 0, c, &result[i]); c = SubTwoWords(ss1[i], 0, c, &result[i]);
TTMATH_LOG("UInt::SubVector") //TTMATH_LOG("UInt::SubVector")
return c; return c;
} }
@ -553,7 +553,7 @@ namespace ttmath
uint mask = 1; uint mask = 1;
if( bit > 1 ) if( bit > 0 )
mask = mask << bit; mask = mask << bit;
uint last = value & mask; uint last = value & mask;