- // If the coefficient is -1, it is replaced by a single minus sign
- if (it->coeff.is_equal(_ex1)) {
- it->rest.print(c, precedence());
- } else if (it->coeff.is_equal(_ex_1)) {
- c.s << "-";
- it->rest.print(c, precedence());
- } else if (ex_to<numeric>(it->coeff).numer().is_equal(*_num1_p)) {
- it->rest.print(c, precedence());
- c.s << "/";
- ex_to<numeric>(it->coeff).denom().print(c, precedence());
- } else if (ex_to<numeric>(it->coeff).numer().is_equal(*_num_1_p)) {
- c.s << "-";
- it->rest.print(c, precedence());
- c.s << "/";
- ex_to<numeric>(it->coeff).denom().print(c, precedence());
+ // If the coefficient is negative, separator is "-"
+ if (it.coeff.is_equal(_ex_1) ||
+ ex_to<numeric>(it.coeff).numer().is_equal(*_num_1_p))
+ separator = '-';
+ c.s << separator;
+ if (it.coeff.is_equal(_ex1) || it.coeff.is_equal(_ex_1)) {
+ it.rest.print(c, precedence());
+ } else if (ex_to<numeric>(it.coeff).numer().is_equal(*_num1_p) ||
+ ex_to<numeric>(it.coeff).numer().is_equal(*_num_1_p))
+ {
+ it.rest.print(c, precedence());
+ c.s << '/';
+ ex_to<numeric>(it.coeff).denom().print(c, precedence());