Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Rounding Numbers in for output in GridBox

  • To: mathgroup at smc.vnet.net
  • Subject: [mg25126] Re: Rounding Numbers in for output in GridBox
  • From: Tom Burton <tburton at brahea.com>
  • Date: Sun, 10 Sep 2000 03:14:46 -0400 (EDT)
  • Organization: Brahea, Inc.
  • References: <8p9ktc$1ug@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On 7 Sep 2000 23:03:08 -0400, in comp.soft-sys.math.mathematica you
wrote:

>I would like to have the numbers rounded (or formatted)
>to display to a specified number of digits or decimal points.
>
>The routine below is an attempt at rounding the numbers to two
>decimal places for output in table form using "GridBox."
>
>The problem is that the numbers are displayed to 15 decimal places,
>after they have been rounded...

The standard display processing, which you have replaced, would have
dropped the trailing zeroes. You can force this treatment with the
NumberForm wrapper. Here is one way to do it: 

(*display the new table*)
newstufftable = 
  GridBox[Map[NumberForm[#, {10, 2}] &, newstuff1, {2}], 
        RowLines -> True, 
        ColumnLines -> True] // FrameBox // DisplayForm

I am requesting up to 10 digits total (more than enough) with two to the
right of the decimal point.

Notes: 

(1) NumberForm is Listable, but I think you need to Map onto the first
argument explicitly, as shown above, so that Numberform processes the
second argument (a list!) correctly.

(2) NumberForm passes non-numbers (your headings) unscathed, so there is
no need for MapAt to bypass the headings.
Tom Burton


  • Prev by Date: Re: Mathematica 3.0 & MathReader 4.0
  • Next by Date: Re: writing mathematica script files for the math kernel under linux
  • Previous by thread: Re: Rounding Numbers in for output in GridBox
  • Next by thread: RE: Rounding Numbers in for output in GridBox