MathGroup Archive 2000

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

Search the Archive

Rounding Numbers in for output in GridBox

  • To: mathgroup at smc.vnet.net
  • Subject: [mg25086] Rounding Numbers in for output in GridBox
  • From: "JOHN C ERB" <JOHN_C_ERB at prodigy.net>
  • Date: Thu, 7 Sep 2000 22:28:39 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

I would like to make a nice table for printing.
The table contains strings and numbers.
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.

Any suggestions on displaying a specified number of digits or
decimal points?

I am using Mathematica 4.0.1 and Windows 98, 2nd Ed.

My sample routine:

(* generate a table *)
stuff = Table[Random[Real, {0.1, 100}], {i, 3}, {j, 4}]

(* add column titles *)
columntitles = {"Numb 1", "Numb 2", "Numb 3", "Numb 4"};
stuff1 = Prepend[stuff, columntitles]

(* Display in a table form using GridBox *)
stufftable = 
  GridBox[stuff1, RowLines -> True, ColumnLines -> True] // FrameBox // 
    DisplayForm

(* Round the numbers to two deicmal places *)
newstuff = Round[stuff*100]/100.0
newstuff1 = Prepend[newstuff, columntitles]

(* display the new table *)
newstufftable = 
  GridBox[newstuff1, RowLines -> True, ColumnLines -> True] // FrameBox // 
    DisplayForm


Thanks in advance
John C. Erb

email: John_C_Erb at prodigy.net


  • Prev by Date: Re: Mathematica Publication Question
  • Next by Date: Security considerations in Mathematica&J/Link
  • Previous by thread: Hidden parts of a curve as dashed
  • Next by thread: Re: Rounding Numbers in for output in GridBox