]> www.ginac.de Git - ginac.git/blobdiff - ginac/operators.cpp
- added prefix and postfix increment and decrement operators for class numeric
[ginac.git] / ginac / operators.cpp
index d9882c0e235f5ba5c36e22461c7dc4e1c27e2c38..4d762b305c2424ccb623ad5a6e11a61bfa65681e 100644 (file)
@@ -272,7 +272,39 @@ numeric operator+(numeric const & lh)
 
 numeric operator-(numeric const & lh)
 {
-    return (numeric(-1)*lh);
+    return numMINUSONE()*lh;
+}
+
+/** Numeric prefix increment.  Adds 1 and returns incremented number. */
+numeric& operator++(numeric & rh)
+{
+    rh = rh+numONE();
+    return rh;
+}
+
+/** Numeric prefix decrement.  Subtracts 1 and returns decremented number. */
+numeric& operator--(numeric & rh)
+{
+    rh = rh-numONE();
+    return rh;
+}
+
+/** Numeric postfix increment.  Returns the number and leaves the original
+ *  incremented by 1. */
+numeric operator++(numeric & lh, int)
+{
+    numeric tmp = lh;
+    lh = lh+numONE();
+    return tmp;
+}
+
+/** Numeric Postfix decrement.  Returns the number and leaves the original
+ *  decremented by 1. */
+numeric operator--(numeric & lh, int)
+{
+    numeric tmp = lh;
+    lh = lh-numONE();
+    return tmp;
 }
 
 // binary relational operators ex with ex