changed: the way of using Big::SetSign()
the method do not check whether there is a zero or not now (even if there's a zero the method can set a sign bit) I changed this due to some prior errors (errors corrected in revision 17, 49 and 58) added: in Big::MulInt() checking whether the values are zeros and if so the metdhod returns zero immediately removed: file TODO (I didn't use it) git-svn-id: svn://ttmath.org/publicrep/ttmath/trunk@66 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
4f3f05fa9d
commit
4d0241c9c9
5
TODO
5
TODO
|
@ -1,5 +0,0 @@
|
|||
TODO TTMath Library
|
||||
===================
|
||||
|
||||
* Add functions for generating random values
|
||||
* Add something like NaN to the Big<> type
|
|
@ -1536,7 +1536,7 @@ namespace ttmath
|
|||
{
|
||||
if( x.IsZero() )
|
||||
{
|
||||
// there isn't root(0;0)
|
||||
// there isn't root(0;0) - we assume it's not defined
|
||||
if( err )
|
||||
*err = err_improper_argument;
|
||||
|
||||
|
@ -1685,7 +1685,14 @@ namespace ttmath
|
|||
c += x.PowFrac(newindex); // here can only be a carry
|
||||
|
||||
if( change_sign )
|
||||
{
|
||||
// the value of x should be different from zero
|
||||
// (x is actually tested by RootCheckXZero)
|
||||
TTMATH_ASSERT( x.IsZero() == false )
|
||||
|
||||
x.SetSign();
|
||||
}
|
||||
|
||||
|
||||
if( err )
|
||||
*err = c ? err_overflow : err_ok;
|
||||
|
|
|
@ -99,7 +99,7 @@ public:
|
|||
/*!
|
||||
this method moves all bits from mantissa into its left side
|
||||
(suitably changes the exponent) or if the mantissa is zero
|
||||
it sets the exponent as zero as well
|
||||
it sets the exponent to zero as well (and clears the sign bit)
|
||||
|
||||
it can return a carry
|
||||
the carry will be when we don't have enough space in the exponent
|
||||
|
@ -124,7 +124,7 @@ public:
|
|||
private:
|
||||
|
||||
/*!
|
||||
if mantissa is equal zero this method sets exponent to zero and
|
||||
if the mantissa is equal zero this method sets exponent to zero and
|
||||
info without the sign
|
||||
|
||||
it returns true if there was the correction
|
||||
|
@ -430,7 +430,7 @@ public:
|
|||
|
||||
|
||||
/*!
|
||||
it's testing whether there is a value zero or not
|
||||
testing whether there is a value zero or not
|
||||
*/
|
||||
bool IsZero() const
|
||||
{
|
||||
|
@ -492,13 +492,13 @@ public:
|
|||
e.g.
|
||||
-1 -> -1
|
||||
2 -> -2
|
||||
|
||||
we do not check whether there is a zero or not, if you're using this method
|
||||
you must be sure that the value is different from zero
|
||||
*/
|
||||
void SetSign()
|
||||
{
|
||||
if( IsZero() )
|
||||
return;
|
||||
|
||||
info |= TTMATH_BIG_SIGN;
|
||||
info |= TTMATH_BIG_SIGN;
|
||||
}
|
||||
|
||||
|
||||
|
@ -806,9 +806,18 @@ public:
|
|||
*/
|
||||
uint MulInt(sint ss2)
|
||||
{
|
||||
if( ss2 == 0 )
|
||||
{
|
||||
SetZero();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( IsZero() )
|
||||
return 0;
|
||||
|
||||
if( IsSign() == (ss2<0) )
|
||||
{
|
||||
// the signs are the same, the result is positive
|
||||
// the signs are the same (both are either - or +), the result is positive
|
||||
Abs();
|
||||
}
|
||||
else
|
||||
|
@ -818,7 +827,8 @@ public:
|
|||
}
|
||||
|
||||
if( ss2<0 )
|
||||
ss2 = 0 - ss2;
|
||||
ss2 = -ss2;
|
||||
|
||||
|
||||
return MulUInt( uint(ss2) );
|
||||
}
|
||||
|
@ -826,7 +836,7 @@ public:
|
|||
|
||||
/*!
|
||||
multiplication this = this * ss2
|
||||
this method returns carry
|
||||
this method returns a carry
|
||||
*/
|
||||
uint Mul(const Big<exp, man> & ss2)
|
||||
{
|
||||
|
@ -859,6 +869,7 @@ public:
|
|||
else
|
||||
{
|
||||
// the signs are different, the result is negative
|
||||
// if the value is zero it will be corrected later in Standardizing method
|
||||
SetSign();
|
||||
}
|
||||
|
||||
|
@ -913,7 +924,7 @@ public:
|
|||
if( IsSign() == ss2.IsSign() )
|
||||
Abs();
|
||||
else
|
||||
SetSign();
|
||||
SetSign(); // if there is a zero it will be corrected in Standardizing()
|
||||
|
||||
c += Standardizing();
|
||||
|
||||
|
@ -1841,6 +1852,10 @@ private:
|
|||
}
|
||||
|
||||
info = 0;
|
||||
|
||||
// the value should be different from zero
|
||||
TTMATH_ASSERT( mantissa.IsZero() == false )
|
||||
|
||||
if( is_sign )
|
||||
SetSign();
|
||||
}
|
||||
|
@ -1932,6 +1947,10 @@ private:
|
|||
mantissa.table[i] = 0;
|
||||
|
||||
info = 0;
|
||||
|
||||
// the value should be different from zero
|
||||
TTMATH_ASSERT( mantissa.IsZero() == false )
|
||||
|
||||
if( is_sign )
|
||||
SetSign();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue