[Maxima] floating point numbers format
fateman at cs.berkeley.edu
Thu Jun 11 15:53:32 CDT 2009
This has been discussed at least once on the maxima mailing list , in
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:
it is an excerpt from the file nforma.lisp, and should replace the
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
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
which will make 23 print like twenty-three
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.
or any of the other
large number of format directives that are supported by common lisp.
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.
> Maxima mailing list
> Maxima at math.utexas.edu
More information about the Maxima