fixed: buffer overflow in Big::ToInt(Int<int_size> & result)
changed: small optimization in ToInt(Int<int_size> & result) git-svn-id: svn://ttmath.org/publicrep/ttmath/trunk@210 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
02da809583
commit
462ff7cc65
|
@ -8,6 +8,7 @@ Version 0.9.0 prerelease (2009.10.13):
|
|||
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: buffer overflow in Big::ToInt(Int<int_size> & result)
|
||||
* added: support for wide characters (wchar_t, std::wstring)
|
||||
* added: Big::IsInteger()
|
||||
returns true if the value is integer (without fraction)
|
||||
|
|
|
@ -2011,18 +2011,20 @@ 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
|
||||
return 0;
|
||||
|
||||
UInt<man> mantissa_temp(mantissa);
|
||||
sint how_many_bits = exponent.ToInt();
|
||||
|
||||
if( how_many_bits < 0 )
|
||||
{
|
||||
how_many_bits = -how_many_bits;
|
||||
uint index = how_many_bits / TTMATH_BITS_PER_UINT;
|
||||
|
||||
UInt<man> mantissa_temp(mantissa);
|
||||
mantissa_temp.Rcr( how_many_bits % TTMATH_BITS_PER_UINT, 0 );
|
||||
|
||||
for(uint i=index, a=0 ; i<man ; ++i,++a)
|
||||
|
@ -2033,7 +2035,7 @@ public:
|
|||
uint index = how_many_bits / TTMATH_BITS_PER_UINT;
|
||||
|
||||
for(uint i=0 ; i<man ; ++i)
|
||||
result.table[index+i] = mantissa_temp.table[i];
|
||||
result.table[index+i] = mantissa.table[i];
|
||||
|
||||
result.Rcl( how_many_bits % TTMATH_BITS_PER_UINT, 0 );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue