Printing in FORTRAN format(Fm.n)

Mathematica program

(* Printing in FORTRAN format(Fm.n) *)

BeginPackage["printing`"]

printF::usage =
   "printF[x,m,n] gives a string equivalent to number x\n
printed in FORMAT(Fm.n)\n\n
x is real, complex or integer.\n
m, n are integers"

Begin["`private`"]

printF[x_,m_Integer,n_Integer]:=(
c=10^n;
l=m-2;
x1=N[x];
Which[
   Head[x1]===Real||Head[x1]===Integer,
      r=FortranForm[N[Round[c x1]/c]];
      ToString[PaddedForm[r,{l,n},ExponentFunction->(Null&)]],
   Head[x1]===Complex,
      re=FortranForm[N[Round[c x1//Re]/c]];
      im=FortranForm[N[Round[c x1//Im]/c]];
      ToString[PaddedForm[re,{l,n},ExponentFunction->(Null&)]]<>
      ToString[PaddedForm[im,{l,n},ExponentFunction->(Null&)]]
     ]
)

End[]

EndPackage[]


printprogr["printing"];

All Mathematica programs used to study M. - P. series Blank Examples of M. - P. series Blank Work in UMassD BlankWaste icon Unpublished reports

Designed by A. Sergeev.