       RE: Help Formatting Outputs?

• To: mathgroup at smc.vnet.net
• Subject: [mg16977] RE: [mg16966] Help Formatting Outputs?
• From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
• Date: Sat, 10 Apr 1999 02:13:23 -0400
• Sender: owner-wri-mathgroup at wolfram.com

```Daly Gutierrez wrote,
----------------------------

I've been experimenting with formatting results to a desired number
of significant figures.  For the most part, I've found PrintPrecision
(in the "Option Inspector" window) quite useful.  However, I have a
couple of related questions...

1) How can I display Trailing Zeros?
ex: (253/11.2)*(1/0.62137)*(1/3.8754) = 9.60374 (displaying 6
significant
figures using PrintPrecision).  If I change this value to 3, the output
is 9.6 (when in fact I'd like to see 9.60).  I've even tried N[%, 3] but

still get 9.6 as a result.

2) Is there a way to display a result in scientific notation WITHOUT
using ScientificForm[expr]?  Perhaps using a similar feature in the
"Option Inspector" window? ex: (150/2.2046)*6 = 408.237 (again,
displaying 6 significant figures using PrintPrecision).  I would like to

get the same result as ScientificForm[%,1] or 4.x10^2 (in scientific
notation with 1 significant figure).  But it would be nice if I could do

it "in the background" so to speak (like changing the number of
significant figures using PrintPrecision).
------------------------------

I don't know of a way to do this that's completely transparent.  But you

In:=

" 12.300"

In:=

Out=

Now isn't that strange!  We don't get the same head for (x1) and (%).
If you don't like that you can change \$OutputForms using the next line.

In:=
Unprotect[\$OutputForms];
Protect[\$OutputForms];

In:=

Out=
" 13.400"

In:=

Out=

Now (x1) and (%) have the same head, and you don't see (PaddedForm) in the
cell label.  If you want (x1) and (%) to have the head Real and formatted
with trailing zeros I can't help you.  Note that, for positive real numbers
PaddedForm leaves a space where you would get a minus sign for a negative
real number.  In spite of the fact that PaddedForm has several options I
can't find a way to prevent this space.

If you use the definitions below for \$Post and \$Pre PaddedForm will be used
automatically.  However, the darn white space before positive numbers
doesn't look good (see the example below).

In:=
\$Post=(#/.numb_Real:>

In:=
expr=12.3 Sin[8.3 t+2]

Out=
" 12.300" Sin[2+t " 8.300"]

In:=
t=1/2;
expr

Out=
"-1.633"

------------------------

I agree it would be nice to have precise control over the way real numbers
are displayed without changing the head of the numbers.

Regards,
Ted Ersek

```

• Prev by Date: shading in area
• Next by Date: Re: Plot
• Previous by thread: Re: Help Formatting Outputs?
• Next by thread: Dynamic Programming