Re: Number formatting for financial applications
- To: mathgroup at smc.vnet.net
- Subject: [mg27566] Re: [mg27475] Number formatting for financial applications
- From: Tom Burton <tburton at cts.com>
- Date: Wed, 7 Mar 2001 04:08:06 -0500 (EST)
- Organization: Brahea Consulting
- References: <97l3jd$jfu@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hello, The responses I've read so far don't address the original poster's request not to have to wrap a function all the time. Here are two possibilities addressing this shortcoming. In[21]:= $PrePrint = AccountingForm[ #1, {20, 2}, DigitBlock -> 3, NumberSigns -> {"$ -", "$ "} ] & ; In[25]:= $PrePrint = AccountingForm[ #1, {20, 2}, DigitBlock -> 3, NumberFormat -> (StringJoin["$ ", #1] & ) ] & ; Both methods prepend "$ ". The first displays a negative value with a sign; the second, with parentheses. Both display an exact multiple of 10 cents by dropping the final "0". I am unable to make the option NumberPadding work to my satisfaction. (Tried both 4.0 and 4.1.) If one really wants to see the value to the nearest microcent, one can change {20,2} above to {20,8}. But then digits will be blocked on the sides of the decimal point, which the orginal poster apparently does not want. (Why not?) Finally, I would note the advantage of using the AccountingForm function instead of a homegrown function. Because AccountingForm "acts as a 'wrapper', which affects printing, but not evaluation", you can use the displayed number in further calculations without extra effort or loss of accuracy from rounding. Tom The orginial poster had written: >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. Tom