MathGroup Archive 1995

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

Search the Archive

Short form for FortranForm

  • Subject: [mg2863] Short form for FortranForm
  • From: "hedonley at"
  • Date: 30 Dec 1995 03:45:58 -0600
  • Approved:
  • Distribution: local
  • Newsgroups: wri.mathgroup
  • Organization: Indiana University of Pennsylvania
  • Sender: daemon at

>Subject: Short form for FortranForm
>From: hedonley at (H. Edward Donley)
>To: mathgroup at
>Organization: Indiana University of PA

Does anyone know how to create FortranForm numbers with just a few digits
of precision, something analogous to the second argument of N[number,
precision]?  My attempt, below, worked for the first example but not for
the second.  And I have a suspicion that there is a much simpler solution.

    CompactForm[a_Real, precisiongoal_Integer] :=
        digits = Log[10, Abs[a]];
        scalefactor =
          10^(Sign[digits] Floor[Abs[digits]] - precisiongoal);
        FortranForm[N[ Round[a/scalefactor] scalefactor ]]


Thanks for any help you can give to me.

Ed Donley

H. Edward Donley
Mathematics Department
Indiana University of Pennsylvania
Indiana, PA  15705

hedonley at

  • Prev by Date: Re: Re: FindMinimum and NIntegrate
  • Next by Date: Should I get Matlab or Mathematica or ?
  • Previous by thread: Short form for FortranForm
  • Next by thread: Should I get Matlab or Mathematica or ?