Re: Re: PrintPrecision
- To: mathgroup at smc.vnet.net
- Subject: [mg23175] Re: [mg23160] Re: PrintPrecision
- From: David Withoff <withoff at wolfram.com>
- Date: Thu, 20 Apr 2000 23:48:46 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
> In article <8djlqq$7rj at smc.vnet.net>, "John Flint" <j.flint at itf.sdu.dk> wrote: > > :When I use the Options Inspector to change the notebook 'Formatting > :Options', 'Expression Formating', 'Display Options', 'PrintPrecision' to say > :3 in order to see more of a matrix in my window then som numbers come > :out as expected (ex. -3.22) while others still have a lot of digits (ex. > :27.536488564494144). How can I make them all small? > > I'm sick to death of the bizarre formatting rules which Mathematica > uses. I want a plain, simple, fixed-format, in which a "1" will print > as a "1.0000" (NOT "1.") and a "1.39281" will print as a "1.3928" and a > "1.31" will print as a "1.3100". I've tried NumberForm, I've tried > PaddedForm, I've tried writing the damned things to a file--and I cannot > get the simple, classical, traditional "f6.4". HOW DO I DO THIS?! > > And when I print it to a file, I **don't** want to find the file filled > with a bunch of "NumberForm[..."'s. > > And as I mentioned in another post, **my** Options Inspector won't make > any changes. > > --Ron Bruck PaddedForm[expr, {6, 4}] did what you described when I tried it. In[1]:= PaddedForm[1, {6, 4}] Out[1]//PaddedForm= 1.0000 In[2]:= PaddedForm[1.39281, {6, 4}] Out[2]//PaddedForm= 1.3928 In[3]:= PaddedForm[1.31, {6, 4}] Out[3]//PaddedForm= 1.3100 PaddedForm also works for writing this format to a file. In[4]:= Write["file", OutputForm[PaddedForm[ ColumnForm[{1, 1.39281, 1.31}], {6, 4}]]] In[5]:= Close["file"] ; In[6]:= !!file 1.0000 1.3928 1.3100 The Option Inspector is irrelevant for this task. The PrintPrecision option controls the number of digits used to display machine inexact numbers in typeset formats (StandardForm and TraditionalForm). This will have no effect on the display of the integer 1, or on the display of high-precision numbers, or in non-typeset formats such as OutputForm that are typically of interest when writing numbers to a file. It would not be terribly difficult to program formatting functions in Mathematica to replicate Fortran-like syntax for format control, so you could for example enter MyForm[1.39281, f6.4] and get essentially what you get in Fortran. The functionality Mathematica is sufficiently similar to the functionality of Fortran for these kinds of tasks that I don't see a good reason (other than not wanting to learn new notation) to prefer one over the other, but perhaps someone who sees a good reason to do so will program this aspect of Fortran syntax into Mathematica some day. It is unlikely that your Option Inspector won't make any changes, but hopefully someone else will address that issue. Dave Withoff Wolfram Research