- pseries::print(): did not insert parenthesis when needed for precedence.
[ginac.git] / ginac / pseries.cpp
index 9dc0921ed3317a299ee15533b11789a16d6ad130..bed134ed10abfab7506c7f8cbecd8ede4662191b 100644 (file)
@@ -163,6 +163,7 @@ basic *pseries::duplicate() const
 void pseries::print(std::ostream &os, unsigned upper_precedence) const
 {
        debugmsg("pseries print", LOGLEVEL_PRINT);
+       if (precedence<=upper_precedence) os << "(";
        for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i) {
                // omit zero terms
                if (i->rest.is_zero())
@@ -196,6 +197,7 @@ void pseries::print(std::ostream &os, unsigned upper_precedence) const
                        os << Order(power(var-point,i->coeff));
                }
        }
+       if (precedence<=upper_precedence) os << ")";
 }
 
 
@@ -891,8 +893,18 @@ ex ex::series(const ex & r, int order, unsigned options) const
        return e;
 }
 
+//////////
+// static member variables
+//////////
+
+// protected
+
+unsigned pseries::precedence = 38;  // for clarity just below add::precedence
+
+//////////
+// global constants
+//////////
 
-// Global constants
 const pseries some_pseries;
 const std::type_info & typeid_pseries = typeid(some_pseries);