Re: Number formatting for financial applications
- To: mathgroup at smc.vnet.net
- Subject: [mg27503] Re: [mg27475] Number formatting for financial applications
- From: David Withoff <withoff at wolfram.com>
- Date: Thu, 1 Mar 2001 03:53:29 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
> I am having a hard time getting the format I need in my output. For some
> reason Mathematica keeps putting things in engineering form when I just want
> a long number
>
> e.g. I want to display this number
>
> 101522688.1906242
>
> like this
>
> $ 101,522,688.1906242 (I can do without the $ if it's too hard)
>
> How can I achieve this without writing ten different tags each time. I just
> want to have a formula with this output instead of having to wrap the
> formula with AccountingForm[], NumberForm[], DigitBlock, etc. It looks
> really ugly when I print it.
>
> thanks
> Felipe
Well, you will obviously have to wrap the result with *something*, since
the computer will otherwise have no way of knowing what you want.
Most of what you described can be achieved built-in functionality.
In[1]:= myform[p_] :=
AccountingForm[p, Infinity, NumberFormat -> ("$ " <> #1 &),
DigitBlock -> 3]
In[2]:= myform[101522688.1906242]
Out[2]//AccountingForm= $ 101,522,688.190,624,2
The only difference between this result and your example is
the commas to the right of the decimal point. Removing those
commas would require another step.
Dave Withoff
Wolfram Research