public static MInteger AddOptimized(MInteger firstInteger, MInteger secondInteger, bool carry) { if (firstInteger.IsNull() || secondInteger.IsNull()) { if (firstInteger.IsNull()) { return(MayAddOneToLast(secondInteger, carry)); } else { return(MayAddOneToLast(firstInteger, carry)); } } (bool resultCarry, bool bit) = AddBits(firstInteger.FirstBit(), secondInteger.FirstBit(), carry); return((new MInteger(bit)).Append(AddOptimized(firstInteger.RemoveFirst(), secondInteger.RemoveFirst(), resultCarry))); }
public bool EqualsInteger(MInteger integer) { if (IsNull()) { if (integer.IsNull()) { return(true); } return(false); } if (integer.IsNull()) { return(false); } if (FirstBit() == integer.FirstBit()) { return(RemoveFirst().EqualsInteger(integer.RemoveFirst())); } return(false); }
public MInteger Append(MInteger integer) { if (integer.IsNull()) { return(this); } MCircularListNode <bool> node = integer.list.firstNode; while (true) { Append(node.nodeValue); if (object.ReferenceEquals(node, integer.list.lastNode)) { return(this); } node = node.nextNode; } }