TBitField TBitField::operator|(const TBitField &bf) // операция "или"
{
	if (BitSize == bf.BitSize)
	{
		TBitField tmp(BitSize);
	    for (int i=0; i< BitSize; i++)
	    {
		    int tmpval = (GetBit(i) || bf.GetBit(i));
		    if (tmpval == 0)
			    tmp.ClrBit(i);
		    else
			    tmp.SetBit(i);
	    }
	    return tmp;
	}
	else
	{
		if (BitSize > bf.BitSize)
		{
			TBitField tmp(BitSize);
			for (int i = 0; i < bf.BitSize; i++)
			{
				int tmpval = (GetBit(i) || bf.GetBit(i));
		        if (tmpval == 0)
			        tmp.ClrBit(i);
		        else
			        tmp.SetBit(i);
			}
			for (int i = bf.BitSize; i < BitSize; i++)
				if (GetBit(i) == 1)
					tmp.SetBit(i);
				else
					tmp.ClrBit(i);
			return tmp;
		}
		else
		{
			TBitField tmp(bf.BitSize);
			for (int i = 0; i < BitSize; i++)
			{
				int tmpval = (GetBit(i) || bf.GetBit(i));
		        if (tmpval == 0)
			        tmp.ClrBit(i);
		        else
			        tmp.SetBit(i);
			}
			for (int i = BitSize; i < bf.BitSize; i++)
				if (bf.GetBit(i) == 1)
					tmp.SetBit(i);
				else
					tmp.ClrBit(i);
			return tmp;
		}
	}
}
Example #2
0
int TBitField::operator!=(const TBitField &bf) const // сравнение
{
	if (BitLen!=bf.BitLen)
		return 1;
	for (int i=0;i<BitLen;i++)
		if (GetBit(i)!=bf.GetBit(i))
			return 1;
    return 0;
}
int TBitField::operator!=(const TBitField &bf) const // сравнение
{
   if (BitSize != bf.BitSize)
		return 1;
	else
	{
		for (int i = 0;i < BitSize; i++)
			if (GetBit(i) != bf.GetBit(i))
				return 1;
        return 0;
	}
}
Example #4
0
int TBitField::operator==(const TBitField &bf) const // сравнение
{
	int res=1;
	if (BitLen!=bf.BitLen)
		res=0;
	else 
	{
		for (int i=0; i < BitLen ;i++)
			if (this->GetBit(i)!=bf.GetBit(i))
			{
				res=0;
				break;
			}
	}
	return res;
}
Example #5
0
// конструктор преобразования типа
TSet::TSet(const TBitField &bf) : BitField(bf)
{
	MaxPower=bf.GetLength();
}
Example #6
0
// конструктор преобразования типа
TSet::TSet(const TBitField &bf) : BitField(bf), MaxPower(bf.GetLength())
{
}