Equivalent of evalf for numeric (for fractions)
Hi again, How can I convert a GiNaC::numeric that contains a fraction (or even a integer, for that matter) into a numeric with the real representation of the fraction? Currently I'm adding "0.0" to the numeric to force it into a real number. This works, but is ugly. How about an "evalf" function for GiNaC::numeric? -- I'm always looking for a new idea that will be more productive than its cost. -- David Rockefeller Eduardo M Kalinowski (ekalin@iname.com) http://move.to/hpkb http://cami-ufpr.hpg.com.br - To UNSUBSCRIBE, email to ginac-list@ginac.de with a subject of "unsubscribe".
On Mon, 4 Dec 2000, Eduardo M Kalinowski wrote:
How can I convert a GiNaC::numeric that contains a fraction (or even a integer, for that matter) into a numeric with the real representation of the fraction? Currently I'm adding "0.0" to the numeric to force it into a real number. This works, but is ugly. How about an "evalf" function for GiNaC::numeric?
This is exactly why GiNaC::numeric has a method "evalf" and internally it is doing exactly what you are suggesting. :-) Regards -richy. -- Richard Kreckel <Richard.Kreckel@Uni-Mainz.DE> <http://wwwthep.physik.uni-mainz.de/~kreckel/> - To UNSUBSCRIBE, email to ginac-list@ginac.de with a subject of "unsubscribe".
"Richard B. Kreckel" wrote:
On Mon, 4 Dec 2000, Eduardo M Kalinowski wrote:
How can I convert a GiNaC::numeric that contains a fraction (or even a integer, for that matter) into a numeric with the real representation of the fraction? Currently I'm adding "0.0" to the numeric to force it into a real number. This works, but is ugly. How about an "evalf" function for GiNaC::numeric?
This is exactly why GiNaC::numeric has a method "evalf" and internally it is doing exactly what you are suggesting. :-)
You're right, there is, but it returns an ex, not a numeric. I cannot think of a possibility in which the result of evalf on a numeric could not be represented by another numeric, and needs an ex. Anyway, this leads to one other question I would eventually have to ask, which is in the next message. -- It's from Casablanca. I've been waiting all my life to use that line. -- Woody Allen, "Play It Again, Sam" Eduardo M Kalinowski (ekalin@iname.com) http://move.to/hpkb http://cami-ufpr.hpg.com.br - To UNSUBSCRIBE, email to ginac-list@ginac.de with a subject of "unsubscribe".
participants (2)
-
Eduardo M Kalinowski
-
Richard B. Kreckel