Rounding

Richard B. Kreckel kreckel at ThEP.Physik.Uni-Mainz.DE
Tue Jan 25 18:50:49 CET 2000


On Tue, 25 Jan 2000, Micah McCurdy wrote:

> Forgive this simplistic question, but I'm going around the bend.
> I have an ex, on which I've performed many manipulations, of which I want the
> value. It's a polynomil in x, and evaluating poly.subs(x==valThatIWant) gives
> me another ex, which, when output, is the correct number, to 17 decimal places.
> I need this number as a double value, only to 10 decimal places. What can I do?

You want to convert the ex to a naked numeric first using ex_to_numeric(),
then you can use the method to_double() defined on numeric.

> Setting Digits to various values in various places does not seem to change
> anything. Any help is welcome.

This is because if you, say, increment Digits by one nothing happens
unless a new word for storing the float is touched.  This means you have
to increment about 9 Digits on a machine with 32 bit words until you
really get a change.  The output function for numerics doesn't do anything
interesting, it falls back to CLN, which is why you see it how CLN stores
it.

Regards
     -rbk.
-- 
Richard Kreckel
<Richard.Kreckel at Uni-Mainz.DE>
<http://wwwthep.physik.uni-mainz.de/~kreckel/>


-
To UNSUBSCRIBE, email to ginac-list at ginac.de with a subject of "unsubscribe".



More information about the GiNaC-list mailing list