MathGroup Archive 2005

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

Search the Archive

How to output float in Fortran form from Mathematica high precision number


I'd like to compute Bessel function in Mathematica with high precision
and output it in form for input it in fortran program.

OutputStream[strm, 1]
roundReal[x_, n_] := 10.^(-n) Round[10^n x]
OutputFormData[]
SetDirectory["D:\TMP"]
strm = OpenWrite["testbes.txt"]
prec := 500
x1 := SetPrecision[1, prec]
x2 := SetPrecision[2, prec]
dx := SetPrecision[1, prec]
n1 := SetPrecision[1, prec]
n2 := SetPrecision[1000, prec]
dn := SetPrecision[1, prec]
Do[Do[Write[strm, 
   FortranForm[MantissaExponent[N[BesselJ[n, x], prec]]], 
   FortranForm[MantissaExponent[N[BesselY[n, x], prec]]]],
 {n, n1, n2, dn}], {x, x1, x2, dx}]
Close[strm]

gives something like that
List(0.4400505857449335159596822037189149131273723019927652511367581717801382\
22478015547930796592381198254162606413647919983706048911708467231602807674502\
24327981834047353357370821313128426083911211323361641344640781853844152804847\
53267482993683173482977170169722420083977889847208425873705757084398422930770\
74095523362060185360415772992493229757747946150577793631888988863318559886836\
38237174625112208278787141592516308753589377855090803012032268147809601185942\
2171418557117866024107250170328467205798516,0)List(-0.78121282130028871654715\
00000479648205499063907164446078438332461277843915385602167276292380048056346\
10359440695054799546384072763088051135894299724496925283869916704560256547939\
49244470426592964777790550024750925830506854918050627057465600054365011670706\
89836489058471101913575173418974510058673438777241131647428234630931617954458\
98530392572370728528133991215501769790733023504549146823644700048451983374912\
57400947944009136817464165439846747711917028102225916513551033407709857277670\
40234678447868,0)

I need in output mantissa and exponent separately as fortran
understandable numbers

+1.234567890123456e+0000

Any advice will be appreciated


  • Prev by Date: Re: Question regarding procedures
  • Next by Date: Re: Piecewise Integration Woes
  • Previous by thread: is there a way to have the "Get" accept C formed %E numbers like Read does for Real?
  • Next by thread: Re: Mathematica Programmer vs. Programming in Mathematica/ functions and OOP