diff --git a/ttmath/ttmathbig.h b/ttmath/ttmathbig.h index e58c894..7b4fb4f 100644 --- a/ttmath/ttmathbig.h +++ b/ttmath/ttmathbig.h @@ -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 operator&(const Big & p2) const + { + Big temp( *this ); + + temp.BitAnd(p2); + + return temp; + } + + + Big & operator&=(const Big & p2) + { + BitAnd(p2); + + return *this; + } + + + Big operator|(const Big & p2) const + { + Big temp( *this ); + + temp.BitOr(p2); + + return temp; + } + + + Big & operator|=(const Big & p2) + { + BitOr(p2); + + return *this; + } + + + Big operator^(const Big & p2) const + { + Big temp( *this ); + + temp.BitXor(p2); + + return temp; + } + + + Big & operator^=(const Big & p2) + { + BitXor(p2); + + return *this; + } + + + + + + /*! this method makes an integer value by skipping any fractions diff --git a/ttmath/ttmathint.h b/ttmath/ttmathint.h index f2de20c..a8af569 100644 --- a/ttmath/ttmathint.h +++ b/ttmath/ttmathint.h @@ -1397,11 +1397,9 @@ public: Int & operator%=(const Int & p2) { - Int temp(*this); Int remainder; - temp.Div(p2, remainder); - + Div(p2, remainder); operator=(remainder); return *this; diff --git a/ttmath/ttmathuint.h b/ttmath/ttmathuint.h index 34f7a20..5041c8b 100644 --- a/ttmath/ttmathuint.h +++ b/ttmath/ttmathuint.h @@ -3259,11 +3259,9 @@ public: UInt & operator%=(const UInt & p2) { - UInt temp(*this); UInt remainder; - temp.Div( p2, remainder ); - + Div( p2, remainder ); operator=(remainder); return *this; @@ -3312,7 +3310,78 @@ public: } - UInt operator>>(int move) + + /*! + * + * bitwise operators + * + */ + + UInt operator~() const + { + UInt temp( *this ); + + temp.BitNot(); + + return temp; + } + + + UInt operator&(const UInt & p2) const + { + UInt temp( *this ); + + temp.BitAnd(p2); + + return temp; + } + + + UInt & operator&=(const UInt & p2) + { + BitAnd(p2); + + return *this; + } + + + UInt operator|(const UInt & p2) const + { + UInt temp( *this ); + + temp.BitOr(p2); + + return temp; + } + + + UInt & operator|=(const UInt & p2) + { + BitOr(p2); + + return *this; + } + + + UInt operator^(const UInt & p2) const + { + UInt temp( *this ); + + temp.BitXor(p2); + + return temp; + } + + + UInt & operator^=(const UInt & p2) + { + BitXor(p2); + + return *this; + } + + + UInt operator>>(int move) const { UInt temp( *this ); @@ -3330,7 +3399,7 @@ public: } - UInt operator<<(int move) + UInt operator<<(int move) const { UInt temp( *this );