MathGroup Archive 2009

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

Search the Archive

Re: Formatting Numeric Outpuit

  • To: mathgroup at smc.vnet.net
  • Subject: [mg104853] Re: [mg104782] Formatting Numeric Outpuit
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Thu, 12 Nov 2009 06:00:24 -0500 (EST)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <200911101057.FAA19555@smc.vnet.net>
  • Reply-to: murray at math.umass.edu

You may obtain what you want by mapping the appropriate NumberForm 
expression onto the list n1 and feeding that into Column (for the sake 
of this post, I shortened the list to have length 2):

    n1 = RandomReal[100, 2];
    n2 = NumberForm[#, {3, 3}] & /@ n1;
    Column[n2, Right]
91.900
56.100

I don't know how completely to explain why what you tried doesn't work, 
except to note the result of ...

    NumberForm[n1, {3, 3}] // FullForm

..which shows a NumberForm expression. Remember that NumberForm does not 
affect evaluation, only display.

But I've long considered the same effect you observed as an a 
Mathematica annoyance. Like you, I've always expected the NumberForm to 
change the display of all the numbers no matter where they're 
subsequently embedded.

I don't know why this annoying behavior cannot be changed, although from 
my perspective it's hard to tell what effects the change might make as 
they ricochet through the whole system.

BenT wrote:
> Please consider these Mathematica 7 code Input lines:
> 
> n1 = RandomReal[100, 10]
> 
> n2 = NumberForm[n1, {3, 3}]
> 
> Column[n2, Right]
> 
> What I expected to get was "ignored", namely right aligned "arbitrary"
> numeric data with 3 digits to the right, and 3 digits to the left of
> the decimal point) formatted in a single column. How can this be
> achieved with any numeric list of data?
> 
> --- Benjamin Tubb
> 

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305


  • Prev by Date: Re: Cumulative probability that random walk variable exceeds given
  • Next by Date: Re: Cumulative probability that random walk variable exceeds given
  • Previous by thread: Re: Formatting Numeric Outpuit
  • Next by thread: Re: Re: Formatting Numeric Outpuit