Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

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



  • Prev by Date: Please help with a Hypergeometric2F1 problem...
  • Next by Date: Re: how to XY plot a list of complex numbers?
  • Previous by thread: Re: Re: Please help with a Hypergeometric2F1 problem...
  • Next by thread: Re: Q: open palletes in a specific on screen position.