- added AboutEqualWithoutSign() to big<> to allow 'suppression' of some unexpected results (that are perfectly logical though, given the possibly unrepresentable nature of binary representation of decimals) like
big<>("10.456466") * 2 == big<>("20.912932") resulting in FALSE result. git-svn-id: svn://ttmath.org/publicrep/ttmath/branches/chk@171 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
de64608eba
commit
de58378488
|
@ -3864,26 +3864,36 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
bool IsNearZero() const
|
||||
bool AboutEqualWithoutSign(const Big<exp,man> & ss2, int nBitsToIgnore = 4) const
|
||||
{
|
||||
// we should check the mantissas beforehand because sometimes we can have
|
||||
// a mantissa set to zero but in the exponent something another value
|
||||
// (maybe we've forgotten about calling CorrectZero() ?)
|
||||
if( mantissa.IsZero() )
|
||||
if( mantissa.IsZero() && ss2.mantissa.IsZero())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
UInt<man> m(mantissa);
|
||||
if( exponent==ss2.exponent )
|
||||
{
|
||||
if (mantissa == ss2.mantissa)
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
ASSERT(nBitsToIgnore < TTMATH_BITS_PER_UINT);
|
||||
|
||||
m.Rcr(man*3); // pi * thumb rule...
|
||||
|
||||
return(m.IsZero());
|
||||
for (int n = man-1; n > 0; --n)
|
||||
{
|
||||
if (mantissa.table[n] != ss2.mantissa.table[n])
|
||||
return(false);
|
||||
}
|
||||
uint nMask = ~((1 << nBitsToIgnore) - 1);
|
||||
return((mantissa.table[0] & nMask) == (ss2.mantissa.table[0] & nMask));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool operator<(const Big<exp,man> & ss2) const
|
||||
{
|
||||
if( IsSign() && !ss2.IsSign() )
|
||||
|
@ -3914,16 +3924,6 @@ public:
|
|||
}
|
||||
|
||||
|
||||
bool operator^=(const Big<exp,man> & ss2) const
|
||||
{
|
||||
if( IsSign() != ss2.IsSign() )
|
||||
return false;
|
||||
|
||||
return AboutEqualWithoutSign( ss2 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool operator>(const Big<exp,man> & ss2) const
|
||||
{
|
||||
if( IsSign() && !ss2.IsSign() )
|
||||
|
|
Loading…
Reference in New Issue