Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

Re: ToString Awkwardness

  • To: mathgroup at smc.vnet.net
  • Subject: [mg126855] Re: ToString Awkwardness
  • From: Christoph Lhotka <christoph.lhotka at fundp.ac.be>
  • Date: Thu, 14 Jun 2012 05:28:08 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201206130855.EAA03690@smc.vnet.net>

Hi,

  you have some control on it using the FormatType option:

   
"f(x)="<>ToString[8.71*^-15,FormatType->#]&/@{TraditionalForm,CForm,InputForm,StandardForm}

   {f(x)=8.71*10^-15,f(x)=8.71e-15,f(x)=8.71*^-15,f(x)=8.71`*^-15}

Hope that helps,

  Christoph

PS: the "funny" form is the one which would render correctly on a console


On 06/13/2012 10:55 AM, Kevin J. McCann wrote:
> I have several plots with annotation that includes parameter values. I
> am using ToString inside a Text command to do this, and all is well
> unless the values are small so that the results are in scientific
> notation. When this happens, I get something like this:
>
> "f(x) = "<>  ToString[8.71 10^-15]
>
> f(x) =        -15
>          8.71 10
>
> Which is a bit awkward looking in the plot. Upon further investigation,
> I looked at the FullForm of the above and got:
>
> "f(x) =        -15\n8.71 10"
>
> So, I see why the output "looks funny". The exponent is treated
> separately from the 10. Any suggestions for nicer looking output?
>
> Thanks,
>
> Kevin
>




  • Prev by Date: Re: Varying a constant in an ODE to Manipulate solution
  • Next by Date: Re: modulo solving lacking domain?
  • Previous by thread: Re: ToString Awkwardness
  • Next by thread: Re: ToString Awkwardness