If all you want to do is compute an ANSWER to some precision, you do not
need such an elaborate construction.
piprec(fpprec) /* compute pi to given precision by binding fpprec*/
:= bfloat(%pi);
piprec(100);
The convoluted stuff has only to do with parsing numbers at the time a
function is defined or a line is typed by the user. If you want to define a
program foo that has very long bfloat constants in it, you could do this:
block([fpprec],(''(fpprec:1000), foo(x):=
1.2345677889089080980980989080b0*x+6564654.3453423252353345343535345);
or something like that.
then foo will always have those high-precision constants.
> -----Original Message-----
> From: maxima-bounces at math.utexas.edu
> [mailto:maxima-bounces at math.utexas.edu] On Behalf Of van Nek
> Sent: Tuesday, January 15, 2008 9:59 AM
> To: fateman at EECS.Berkeley.EDU
> Cc: Maxima at math.utexas.edu
> Subject: Re: [Maxima] Maxima parser and global parameters
>
> Richard,
>
> thank you for your answer. I played around with it and tried
> to find a way to change the
> precision just locally in a block and to preserve the
> original fpprec in top level.
>
> The workaround I found for defining a function with different
> local fpprec was a three step
> definition:
>
> (%i1) save_global: fpprec$
> (%i2) foo():= block( [fpprec:20], ''(fpprec:20),
> print(1.12345678901234567890b0, bfloat(%pi)) )$
> (%i3) fpprec: save_global$
>
> Now foo works as intended.
>
> (%i4) foo()$
> 1.1234567890123456789b0 3.1415926535897932385b0
>
> Is there a more elegant way?
>
> Volker van Nek
>
>
> Am 12 Jan 2008 um 10:36 hat Richard Fateman geschrieben:
>
> >
> > try
> > ( ''(fpprec:100), [fpprec, 1.123456890123456890123456890b0] );
> > That is two ' [apostrophe or single-quote).
> >
> >
> >
> > From: maxima-bounces at math.utexas.edu
> > [mailto:maxima-bounces at math.utexas.edu]
> > On Behalf Of van Nek
> > Sent: Saturday, January 12, 2008 9:23 AM
> > To: Maxima at math.utexas.edu
> > Subject: Maxima parser and global parameters
> >
> >
> >
> > (%i1) ( fpprec:100, [fpprec, 1.123456890123456890123456890b0]
> > );
> > (%o1) [100, 1.123456890123457b0]
> > (%i2) ( ibase:2, [ibase, 11111111] );
> > (%o2) [2, 11111111]
> >
> >
> > This shows me that in a first step the complete expression is
> > read and parsed and in a
> > second step the expressions are evaluated from left to right.
> >
> > Is it generally possible, that expressions like fpprec:100 can
> > have an influence on the
> > parser inside of the same expression, or can it only have effect
> > on the next read in
> > expression?
> >
> > Volker van Nek
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>