On Wed, Nov 14, 2007 at 04:41:03PM +0100, Martin Sandve Alnæs wrote:
Is it possible to make evalf() let integer constants stay integers?
evalf() turns exact numbers into inexact _by definition_. Keeping the coefficient exact (for instance, integer) does not make sense anyway, since they are multiplied by inexact number. If you still insist on it, you could roll down your own evalf-alike function, e.g. struct weird_evalf() : public map_function { ex operator()(const ex& e) { if (is_a<add>(e) || is_a<mul>(e)) return e.map(*this); if (is_a<power>(e)) return power(e.op(0).map(*this), e.op(1)); if (is_a<numeric>(e)) return e; else return e.evalf(); } Best regards, Alexei -- All science is either physics or stamp collecting.