From c349526385abdaca21fabc53d23b603d4510abe0 Mon Sep 17 00:00:00 2001 From: Richard Kreckel Date: Tue, 30 Nov 1999 22:06:14 +0000 Subject: [PATCH] - changed mul::print() to behave similar to add::print() --- ginac/print.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ginac/print.cpp b/ginac/print.cpp index 1df9cd2f..f90a40ce 100644 --- a/ginac/print.cpp +++ b/ginac/print.cpp @@ -146,7 +146,8 @@ void add::print(ostream & os, unsigned upper_precedence) const if (coeff.csgn()==-1) os << '-'; first=false; } - if (coeff.compare(numONE()) && coeff.compare(numMINUSONE())) { + if (!coeff.is_equal(numONE()) && + !coeff.is_equal(numMINUSONE())) { if (coeff.csgn()==-1) (numMINUSONE()*coeff).print(os, precedence); else @@ -168,10 +169,17 @@ void mul::print(ostream & os, unsigned upper_precedence) const debugmsg("mul print",LOGLEVEL_PRINT); if (precedence<=upper_precedence) os << "("; bool first=true; - if (!overall_coeff.is_equal(exONE())) { - overall_coeff.print(os,precedence); - first=false; + // first print the overall numeric coefficient: + if (ex_to_numeric(overall_coeff).csgn()==-1) os << '-'; + if (!overall_coeff.is_equal(exONE()) && + !overall_coeff.is_equal(exMINUSONE())) { + if (ex_to_numeric(overall_coeff).csgn()==-1) + (numMINUSONE()*overall_coeff).print(os, precedence); + else + overall_coeff.print(os, precedence); + os << '*'; } + // then proceed with the remaining factors: for (epvector::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) { if (!first) { os << '*'; -- 2.44.0