myN[1000!]
- To: mathgroup at smc.vnet.net
- Subject: [mg23233] myN[1000!]
- From: "Hermann Meier" <hmeier at webshuttle.ch>
- Date: Tue, 25 Apr 2000 01:40:36 -0400 (EDT)
- Organization: EUnet AG, Switzerland. A KPNQwest Company.
- Sender: owner-wri-mathgroup at wolfram.com
w = {20!, Prime[10^6]/Prime[10^6+1], N[Exp[25],30], ArcSin[6.]};
SetAttributes[myN,Listable];
myN[cvx_/;!NumberQ[cvx]] := cvx;
myN[cvx_/; (Head[cvx]===Integer || Head[cvx]===Rational),___] :=
NumberForm[cvx,DigitBlock->3,NumberSeparator->" "];
myN[cvx_/; (Head[cvx] === Real || Head[cvx]===Complex), dig_:Infinity] :=
(Off[NumberForm::sigz];
NumberForm[cvx,{Precision[cvx], Min[dig, Accuracy[cvx]]},
DigitBlock->3,NumberSeparator->" ",
ExponentFunction->(Null&)]);
Prepend[w,"TEXT"]//myN gives a NumberForm-output with digit blocks, number
separators and no exponents; nonnumeric input is returned unchanged.
myN[w,dig] or w//myN[#,dig]& gives dig decimal places instead of full
accuracy. (There seems to be no way to show this "better" output in a
message.)
Perhaps myN can be improved upon.
With kind regards
Hermann Meier