+ }
+
+ if (parent)
+ {
+ m_next[op].push_back(b);
+ for (auto add : m_next[ADD])
+ delete add->OperationFactor(new ParanoidNumber(*cpy_b), op);
+ for (auto sub : m_next[SUBTRACT])
+ delete sub->OperationFactor(new ParanoidNumber(*cpy_b), op);
+ }
+ return NULL;
+}
+
+
+
+/**
+ * Performs the operation on a with argument b (a += b, a -= b, a *= b, a /= b)
+ * @returns b if b can safely be deleted
+ * @returns NULL if b has been merged with a
+ * append indicates that b should be merged
+ */
+ParanoidNumber * ParanoidNumber::Operation(ParanoidNumber * b, Optype op, ParanoidNumber ** merge_point, Optype * merge_op)
+{
+
+ if (b == NULL)
+ return NULL;
+
+
+ if (op == SUBTRACT || op == ADD)
+ return OperationTerm(b, op, merge_point, merge_op);
+ if (op == MULTIPLY || op == DIVIDE)
+ return OperationFactor(b, op, merge_point, merge_op);
+ return b;
+}
+
+
+
+string ParanoidNumber::PStr() const
+{
+ stringstream s;
+ for (int i = 0; i < NOP; ++i)
+ {
+ Optype f = Optype(i);
+ s << this;
+ for (auto n : m_next[f])