This has been discussed at least once on the maxima mailing list , in
mid-december 2007.
There is now a short file, in lisp, which alters the format program to
allow for changing the
way numbers are displayed to be anything that common lisp can do, which
is quite a lot.
load into your maxima:
http://www.cs.berkeley.edu/~fateman/lisp/hackform.lisp
it is an excerpt from the file nforma.lisp, and should replace the
corresponding definition
of nformat. I suggest that someone install it in the source code. It
operates exactly the same as
previously, except if you set the variable noted below.
Now you have a variable format_for_numbers which is initialized to
false.
And it should stay false in case anyone other than the display program
is using format. (which apparently happens)
But if you want to see numbers printed in some specific way as set by a
format string, do something
like this:
format_for_numbers: "~R"
which will make 23 print like twenty-three
or
format_for_numbers:"~@R"
which will make 23 print like XXIII
or more conventionally
The "~F" form looks like this--- ~/w/,/d/,/k/,/overflowchar/,/padchar/F.
The parameter /w/ is the width of the field to be printed; /d/ is the
number of digits to print after the decimal point; /k/ is a scale factor
that defaults to zero.
see
http://www.lispworks.com/documentation/HyperSpec/Body/22_cca.htm for
details.
or any of the other
large number of format directives that are supported by common lisp.
RJF
Raymond Toy wrote:
> Giovanni wrote:
>
>> Hi all. It's possible to have an output like the one generated by
>> '%.2f' in a printf() function, in the whole maxima document? The most
>> similar options i've found it's fpprintprec, but it's not the same
>> (it does not control the number of decimal numbers to display).
>>
>>
> I don't think there's any way to control that. (Do you really want to
> print out 10^100 using %.2f?)
>
> But if you really want to do this and know a little bit of lisp, you can
> modify exploden in commac.lisp to print out floats the way you want.
> Might be enough to change the "~vf" to "~v,2f". Also need to modify the
> cond so that we don't use "~ve" if the number is too small or too big.
>
>
> Ray
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>