[Maxima] Re: 1. Formatted output in maxima.
Richard Fateman
fateman at cs.berkeley.edu
Mon Apr 3 16:00:04 CDT 2006
This is a multi-part message in MIME format.
--------------030809070501080602030704
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
in lisp, (fpformat XX) gets you a list of characters
from a bigfloat. so you might do
(coerce (fpformat XX) 'string)
and then print it using ~a specification.
There are also ways of controlling how many digits are printed even
if there are trailing zeros, with some maxima flags.
RJF
Alexei Meremianin wrote:
>Thanks to Richard Fateman for his suggestion (slightly modified here),
>-----------------------------------------------------------
>(%i7) :lisp (defun $my_formatted_output(a) (format t "~%~10,8f~% I am a new line~%" a))
>$MY_FORMATTED_OUTPUT
>(%i7) my_formatted_output (4.4);
>
>4.40000000
> I am a new line
>(%o7) false
>(%i8)
>------------------------------------------------------------
>Does not work with bigfloats.
>How to handle that case?
>
>Alexei Meremianin <avm at mpipks-dresden.mpg.de> writes:
>
>
>
>>Hello,
>>
>>I want to output some formatted data (numbers) to a file.
>>Just need the same as printf does in C - i.e. control the length of mantissa,
>>put some newlines etc.
>>How to do that in maxima?
>>(print and display commands cannot do the job).
>>
>>
>
>
>
--------------030809070501080602030704
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
<tt>in lisp, (fpformat XX) gets you a list of characters<br>
from a bigfloat. so you might do<br>
<br>
(coerce (fpformat XX) 'string)<br>
<br>
and then print it using ~a specification.<br>
There are also ways of controlling how many digits are printed even<br>
if there are trailing zeros, with some maxima flags.<br>
<br>
RJF<br>
<br>
<br>
</tt><br>
Alexei Meremianin wrote:<br>
<blockquote type="cite"
cite="midigzy7ymk6bu.fsf at galilei.mpipks-dresden.mpg.de">
<pre wrap="">Thanks to Richard Fateman for his suggestion (slightly modified here),
-----------------------------------------------------------
(%i7) :lisp (defun $my_formatted_output(a) (format t "~%~10,8f~% I am a new line~%" a))
$MY_FORMATTED_OUTPUT
(%i7) my_formatted_output (4.4);
4.40000000
I am a new line
(%o7) false
(%i8)
------------------------------------------------------------
Does not work with bigfloats.
How to handle that case?
Alexei Meremianin <a class="moz-txt-link-rfc2396E" href="mailto:avm at mpipks-dresden.mpg.de"><avm at mpipks-dresden.mpg.de></a> writes:
</pre>
<blockquote type="cite">
<pre wrap="">Hello,
I want to output some formatted data (numbers) to a file.
Just need the same as printf does in C - i.e. control the length of mantissa,
put some newlines etc.
How to do that in maxima?
(print and display commands cannot do the job).
</pre>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
</body>
</html>
--------------030809070501080602030704--
More information about the Maxima
mailing list