formatTest.frink

Download or view formatTest.frink in plain text format


// This tests the new format functions.
formatTest[num, mindigits=2, maxdigits=30, html=false] :=
{
   if mindigits != maxdigits
   {
      //print[padRight["format" , maxdigits+15, " "]]
      if html
         print["   <TR><TD>"]
         
      print[padRight["formatSig" , maxdigits+15, " "]]
      if html
         print["<TD>"]
      print[padRight["formatSci" , maxdigits+15, " "]]
      if html
         print["<TD>"]
      print[padRight["formatEng" , maxdigits+15, " "]]
      if html
         print["<TD>"]
      print[padRight["formatFix" , maxdigits+15, " "]]
      println[]
   }
   for digits = mindigits to maxdigits
   {
      if html
         print["   <TR><TD>"]
      print[padRight[formatSig[num, 1, digits], maxdigits+15, " "]]
      if html
         print["<TD>"]
      print[padRight[formatSci[num, 1, digits], maxdigits+15, " "]]
      if html
         print["<TD>"]
      print[padRight[formatEng[num, 1, digits], maxdigits+15, " "]]
      if html
         print["<TD>"]
      print[padRight[formatFix[num, 1, digits], maxdigits+15, " "]]
      println[]
   }
}

formatTest[2/3]
println[]
formatTest[2/3000]
println[]
formatTest[2^20 (2/3 + 1/6i)]
println[]
formatTest[(10^20+1)/3, 10, 23]
println[]
formatTest[1,7,6]
for a = -20 to 20
   formatTest[-2/3 * 10^a, 6, 6, true]   


Download or view formatTest.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 20145 days, 19 hours, 4 minutes ago.