To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=5930





------- Additional comments from [email protected] Mon Jul  5 18:48:20 
+0000 2010 -------
#       eng.py
#

def eng (F = 0, fmt = "%fe%d"):
 """
 Formats a floating point number (F) according to the format
 provided (fmt).  Tries to use engineering notation (i.e. the
 exponent is in powers of three).

 Dean Provins, June, 2010
 """
 
 f = abs (F)
 n = 0
 s = +1
 if F < 0:
  s = -1

 if f != 0:
   if f >= 1.:
     while (f >= 100):
       f /= 10.
       n += 1

     f *= 10.
     n -= 1

     while (n % 3):
       n += 1
       f /= 10.
   else:
     while (f < 99):
       f *= 10.
       n -= 1

     while (n % 3):
       n += 1
       f /= 10.

     #  Uncomment these if you want a leading '0.'
     #f /= 10.
     #n += 1

 #S = fmt % (s * f, n)  # store this result in a cell

 return fmt % (s * f, n) # return the formatted string to store in a cell

#       ---------end of the function ---------

if __name__ == "__main__":

#       Some tests...  Try them by running "python eng.py"

  print "some tests"
  print "----------"
  print "0:", eng ()
  print

  print "1.:", eng (1.)
  print "1.23:", eng (1.23)
  print "123:", eng (123)
  print "1234.567:", eng (1234.567)
  print


  print "11.:", eng (11.)
  print

  print "0.4:", eng (0.4)
  
  print

  print "0.004:", eng (0.004)
  print "0.04:", eng (-0.04)
  print

  print "0.001234567E-7:", eng (0.001234567E-7)
  print 
  print "6,000,000:", eng (6000000)
  print "6,000,000,000:", eng (6000000000)
  print "6,000,000,000,000:", eng (6000000000000)
  print
  print "* * * * < 1,000, > 1 * * * * * * * * * * "
  print
  print "111:", eng (111)
  print "222:", eng (222)
  print "333:", eng (333)
  print "444:", eng (444)
  print "555:", eng (555)
  print "666:", eng (666)
  print "777:", eng (777)
  print "888:", eng (888)
  print "999:", eng (999)
  print
  print "* * * * * * * * * * * * * * "
  print
  print "-111:", eng (-111)
  print "-222:", eng (-222)
  print "-333:", eng (-333)
  print "-444:", eng (-444)
  print "-555:", eng (-555)
  print "-666:", eng (-666)
  print "-777:", eng (-777)
  print "-888:", eng (-888)
  print "-999:", eng (-999)
  print
  print "* * * * * * * * * * * * * * "
  print
  print "-0.4:", eng (-0.4)
  print "-0.0004:", eng (-0.0004)
  print "-0.0000004:", eng (-0.0000004)
  print 
  print "-0.004:", eng (-0.004)
  print "1111:", eng (1111)
  print "2222:", eng (2222)
  print "3333:", eng (3333)
  print "4444:", eng (4444)
  print "5555:", eng (5555)
  print "6666:", eng (6666)
  print "7777:", eng (7777)
  print "8888:", eng (8888)
  print "9999:", eng (9999)

---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to