fixed: Big::BigAnd() Big::BigOr() Big::BigXor() should have set NaN
when the argument was negative (they only returned 2) added: some missing operators UInt::operator~() /* bitwise neg */ UInt::operator&() /* bitwise and */ UInt::operator&=() UInt::operator|() /* bitwise or */ UInt::operator|=() UInt::operator^() /* bitwise xor */ UInt::operator^=() Big::operator&() Big::operator&=() Big::operator|() Big::operator|=() Big::operator^() Big::operator^=() for Big<> we do not define bitwise neg git-svn-id: svn://ttmath.org/publicrep/ttmath/trunk@302 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
b3c3dd8c3f
commit
c65dac524a
|
@ -938,7 +938,10 @@ public:
|
|||
return CheckCarry(1);
|
||||
|
||||
if( IsSign() || ss2.IsSign() )
|
||||
{
|
||||
SetNan();
|
||||
return 2;
|
||||
}
|
||||
|
||||
if( IsZero() )
|
||||
return 0;
|
||||
|
@ -998,7 +1001,10 @@ public:
|
|||
return CheckCarry(1);
|
||||
|
||||
if( IsSign() || ss2.IsSign() )
|
||||
{
|
||||
SetNan();
|
||||
return 2;
|
||||
}
|
||||
|
||||
if( IsZero() )
|
||||
{
|
||||
|
@ -1055,7 +1061,10 @@ public:
|
|||
return CheckCarry(1);
|
||||
|
||||
if( IsSign() || ss2.IsSign() )
|
||||
{
|
||||
SetNan();
|
||||
return 2;
|
||||
}
|
||||
|
||||
if( ss2.IsZero() )
|
||||
return 0;
|
||||
|
@ -4945,6 +4954,72 @@ public:
|
|||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
*
|
||||
* bitwise operators
|
||||
* (we do not define bitwise not)
|
||||
*/
|
||||
|
||||
|
||||
Big<exp,man> operator&(const Big<exp,man> & p2) const
|
||||
{
|
||||
Big<exp,man> temp( *this );
|
||||
|
||||
temp.BitAnd(p2);
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
Big<exp,man> & operator&=(const Big<exp,man> & p2)
|
||||
{
|
||||
BitAnd(p2);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Big<exp,man> operator|(const Big<exp,man> & p2) const
|
||||
{
|
||||
Big<exp,man> temp( *this );
|
||||
|
||||
temp.BitOr(p2);
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
Big<exp,man> & operator|=(const Big<exp,man> & p2)
|
||||
{
|
||||
BitOr(p2);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Big<exp,man> operator^(const Big<exp,man> & p2) const
|
||||
{
|
||||
Big<exp,man> temp( *this );
|
||||
|
||||
temp.BitXor(p2);
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
Big<exp,man> & operator^=(const Big<exp,man> & p2)
|
||||
{
|
||||
BitXor(p2);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
this method makes an integer value by skipping any fractions
|
||||
|
||||
|
|
|
@ -1397,11 +1397,9 @@ public:
|
|||
|
||||
Int<value_size> & operator%=(const Int<value_size> & p2)
|
||||
{
|
||||
Int<value_size> temp(*this);
|
||||
Int<value_size> remainder;
|
||||
|
||||
temp.Div(p2, remainder);
|
||||
|
||||
Div(p2, remainder);
|
||||
operator=(remainder);
|
||||
|
||||
return *this;
|
||||
|
|
|
@ -3259,11 +3259,9 @@ public:
|
|||
|
||||
UInt<value_size> & operator%=(const UInt<value_size> & p2)
|
||||
{
|
||||
UInt<value_size> temp(*this);
|
||||
UInt<value_size> remainder;
|
||||
|
||||
temp.Div( p2, remainder );
|
||||
|
||||
Div( p2, remainder );
|
||||
operator=(remainder);
|
||||
|
||||
return *this;
|
||||
|
@ -3312,7 +3310,78 @@ public:
|
|||
}
|
||||
|
||||
|
||||
UInt<value_size> operator>>(int move)
|
||||
|
||||
/*!
|
||||
*
|
||||
* bitwise operators
|
||||
*
|
||||
*/
|
||||
|
||||
UInt<value_size> operator~() const
|
||||
{
|
||||
UInt<value_size> temp( *this );
|
||||
|
||||
temp.BitNot();
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
UInt<value_size> operator&(const UInt<value_size> & p2) const
|
||||
{
|
||||
UInt<value_size> temp( *this );
|
||||
|
||||
temp.BitAnd(p2);
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
UInt<value_size> & operator&=(const UInt<value_size> & p2)
|
||||
{
|
||||
BitAnd(p2);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
UInt<value_size> operator|(const UInt<value_size> & p2) const
|
||||
{
|
||||
UInt<value_size> temp( *this );
|
||||
|
||||
temp.BitOr(p2);
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
UInt<value_size> & operator|=(const UInt<value_size> & p2)
|
||||
{
|
||||
BitOr(p2);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
UInt<value_size> operator^(const UInt<value_size> & p2) const
|
||||
{
|
||||
UInt<value_size> temp( *this );
|
||||
|
||||
temp.BitXor(p2);
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
UInt<value_size> & operator^=(const UInt<value_size> & p2)
|
||||
{
|
||||
BitXor(p2);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
UInt<value_size> operator>>(int move) const
|
||||
{
|
||||
UInt<value_size> temp( *this );
|
||||
|
||||
|
@ -3330,7 +3399,7 @@ public:
|
|||
}
|
||||
|
||||
|
||||
UInt<value_size> operator<<(int move)
|
||||
UInt<value_size> operator<<(int move) const
|
||||
{
|
||||
UInt<value_size> temp( *this );
|
||||
|
||||
|
|
Loading…
Reference in New Issue