Compare commits
5 Commits
Author | SHA1 | Date |
---|---|---|
Tomasz Sowa | 5584adb23d | |
Tomasz Sowa | a4bb0b6f64 | |
Tomasz Sowa | e046aba6d2 | |
Tomasz Sowa | 5ef27bdbd0 | |
Tomasz Sowa | b80f73f16b |
20
CHANGELOG
20
CHANGELOG
|
@ -1,3 +1,23 @@
|
|||
Version 0.8.6 (2009.10.25):
|
||||
* 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')
|
||||
* fixed: buffer overflow in Big::ToInt(Int<int_size> & result)
|
||||
* fixed: powering algorithm in:
|
||||
UInt::Pow(UInt<value_size> pow)
|
||||
Big::Pow(UInt<pow_size> pow)
|
||||
Big::PowUInt(Big<exp, man> pow)
|
||||
when 'pow' was sufficient large the algorithm returned carry
|
||||
but the result could have been calculated correctly
|
||||
|
||||
|
||||
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)
|
||||
|
|
|
@ -1137,15 +1137,17 @@ public:
|
|||
result.SetOne();
|
||||
uint c = 0;
|
||||
|
||||
while( !c && !pow.IsZero() )
|
||||
while( !c )
|
||||
{
|
||||
if( pow.table[0] & 1 )
|
||||
c += result.Mul(start);
|
||||
|
||||
pow.Rcr(1);
|
||||
if( pow.IsZero() )
|
||||
break;
|
||||
|
||||
start_temp = start;
|
||||
c += start.Mul(start_temp);
|
||||
|
||||
pow.Rcr(1);
|
||||
}
|
||||
|
||||
*this = result;
|
||||
|
@ -1247,15 +1249,18 @@ public:
|
|||
one.SetOne();
|
||||
result = one;
|
||||
|
||||
while( !c && pow >= one )
|
||||
while( !c )
|
||||
{
|
||||
if( pow.Mod2() )
|
||||
c += result.Mul(start);
|
||||
|
||||
c += pow.exponent.Sub( e_one );
|
||||
|
||||
if( pow < one )
|
||||
break;
|
||||
|
||||
start_temp = start;
|
||||
c += start.Mul(start_temp);
|
||||
|
||||
c += pow.exponent.Sub( e_one );
|
||||
}
|
||||
|
||||
*this = result;
|
||||
|
@ -1887,6 +1892,7 @@ public:
|
|||
if( exponent > maxbit + sint(int_size*TTMATH_BITS_PER_UINT) )
|
||||
// if exponent > (maxbit + sint(int_size*TTMATH_BITS_PER_UINT)) the value can't be passed
|
||||
// into the 'Int<int_size>' type (it's too big)
|
||||
return 1;
|
||||
|
||||
if( exponent <= maxbit )
|
||||
// our value is from range (-1,1) and we return zero
|
||||
|
@ -4160,9 +4166,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 +4180,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<char>(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<man>::CharToDigit(z, 10) < 0 )
|
||||
break;
|
||||
|
||||
|
||||
ss += z;
|
||||
ss += z;
|
||||
old_z = z;
|
||||
}
|
||||
|
||||
// we're leaving the last read character
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
*/
|
||||
#define TTMATH_MAJOR_VER 0
|
||||
#define TTMATH_MINOR_VER 8
|
||||
#define TTMATH_REVISION_VER 5
|
||||
#define TTMATH_REVISION_VER 6
|
||||
#define TTMATH_PRERELEASE_VER 0
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
@ -2197,32 +2196,27 @@ public:
|
|||
UInt<value_size> start(*this), start_temp;
|
||||
UInt<value_size> result;
|
||||
result.SetOne();
|
||||
|
||||
while( !pow.IsZero() )
|
||||
uint c = 0;
|
||||
|
||||
while( !c )
|
||||
{
|
||||
if( pow.table[0] & 1 )
|
||||
if( result.Mul(start) )
|
||||
{
|
||||
TTMATH_LOG("UInt::Pow(UInt<>)")
|
||||
return 1;
|
||||
}
|
||||
c += result.Mul(start);
|
||||
|
||||
pow.Rcr2_one(0);
|
||||
if( pow.IsZero() )
|
||||
break;
|
||||
|
||||
start_temp = start;
|
||||
// in the second Mul algorithm we can use start.Mul(start) directly (there is no TTMATH_ASSERT_REFERENCE there)
|
||||
if( start.Mul(start_temp) )
|
||||
{
|
||||
TTMATH_LOG("UInt::Pow(UInt<>)")
|
||||
return 1;
|
||||
}
|
||||
|
||||
pow.Rcr2_one(0);
|
||||
c += start.Mul(start_temp);
|
||||
}
|
||||
|
||||
*this = result;
|
||||
|
||||
TTMATH_LOG("UInt::Pow(UInt<>)")
|
||||
|
||||
return 0;
|
||||
return (c==0)? 0 : 1;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -224,7 +224,7 @@ namespace ttmath
|
|||
for( ; i<ss1_size ; ++i)
|
||||
c = AddTwoWords(ss1[i], 0, c, &result[i]);
|
||||
|
||||
TTMATH_LOG("UInt::AddVector")
|
||||
//TTMATH_LOG("UInt::AddVector")
|
||||
|
||||
return c;
|
||||
}
|
||||
|
@ -351,7 +351,7 @@ namespace ttmath
|
|||
for( ; i<ss1_size ; ++i)
|
||||
c = SubTwoWords(ss1[i], 0, c, &result[i]);
|
||||
|
||||
TTMATH_LOG("UInt::SubVector")
|
||||
//TTMATH_LOG("UInt::SubVector")
|
||||
|
||||
return c;
|
||||
}
|
||||
|
@ -553,7 +553,7 @@ namespace ttmath
|
|||
|
||||
uint mask = 1;
|
||||
|
||||
if( bit > 1 )
|
||||
if( bit > 0 )
|
||||
mask = mask << bit;
|
||||
|
||||
uint last = value & mask;
|
||||
|
|
Loading…
Reference in New Issue