diff --git a/ttmath/ttmathbig.h b/ttmath/ttmathbig.h index dea7f09..f1b5f93 100644 --- a/ttmath/ttmathbig.h +++ b/ttmath/ttmathbig.h @@ -4155,139 +4155,6 @@ public: } - /*! - this method compares this and ss2 by ingoring some nBitsToIgnore last bits from mantissas - if nBitsToIgnore is 0 then the method is equivalent to EqualWithoutSign() method - (signs are not checked, we don't check the NaN flag too) - - sample: - Big<1,1> a, b; - a = " 1234.5678"; - b = "-1234.5677999"; - // binary a: 10011010010.100100010101101101010 - // binary b: -10011010010.100100010101101101000 - // two last bits are different - if( a.AboutEqualWithoutSign(b, 2) ) // the result is true - std::cout << "true" << std::endl; - - - ***warning broken*** doesn't work if 'this' or 'ss2' is zero - - - */ - bool AboutEqualWithoutSign(const Big & ss2, uint ignore_bits = 4) const - { - TTMATH_ASSERT( ignore_bits < man*TTMATH_BITS_PER_UINT ) - - if( IsZero() && ss2.IsZero() ) - return true; - - if( exponent == ss2.exponent ) - return AboutEqualExpEqual(mantissa, ss2.mantissa, ignore_bits); - - - UInt exp_diff; - exp_diff = exponent; - exp_diff.Sub(ss2.exponent); - - if( exp_diff == 1 ) - { - // exponent is > ss2.exponent - UInt man_diff(mantissa); - UInt man_temp(ss2.mantissa); - man_temp.Rcr(1, 0); - man_diff.Sub(man_temp); - - return AboutEqualZero(man_diff, ignore_bits); - } - else - if( exp_diff == -1 ) - { - // exponent is < ss2.exponent - UInt man_diff(ss2.mantissa); - UInt man_temp(mantissa); - man_temp.Rcr(1, 0); - man_diff.Sub(man_temp); - - return AboutEqualZero(man_diff, ignore_bits); - } - - // exp_diff is different from zero, one or minus one - - return false; - } - -private: - - - /*! - an auxiliary method for calculating AboutEqualWithoutSign() - we're using it when exponent is equal ss2.exponent - */ - bool AboutEqualExpEqual(const UInt & man1, const UInt & man2, uint ignore_bits) const - { - uint words = ignore_bits / TTMATH_BITS_PER_UINT; - uint bits = ignore_bits % TTMATH_BITS_PER_UINT; - uint i; - - if( bits == 0 ) - { - i = words; - } - else - { - i = words + 1; - uint mask = TTMATH_UINT_MAX_VALUE << bits; - - if( (man1.table[words] & mask) != (man2.table[words] & mask) ) - return false; - } - - for( ; i & man_diff, uint ignore_bits) const - { - uint words = ignore_bits / TTMATH_BITS_PER_UINT; - uint bits = ignore_bits % TTMATH_BITS_PER_UINT; - uint i; - - if( bits == 0 ) - { - i = words; - } - else - { - i = words + 1; - uint mask = TTMATH_UINT_MAX_VALUE << bits; - - if( (man_diff.table[words] & mask) != 0 ) - return false; - } - - for( ; i & ss2) const { if( IsSign() && !ss2.IsSign() )