Tom:

I fell asleep last night after remembering that I'd fogotten
about values < 1.  

The following code (with tests) fixes that oversight (of course,
you may already have fixed it...)

Dean

-- 
                           Dean Provins, P. Geoph.
                         [email protected]
                  KeyID at at pgpkeys.mit.edu:11371: 0x9643AE65
          Fingerprint: 9B79 75FB 5C2B 22D0 6C8C 5A87 D579 9BE5 9643 AE65
def eng (F = 0, fmt = "%fe%d"):
 f = abs (F)
 n = 0
 s = +1
 if F < 0:
  s = -1

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

     f *= 10.
     n -= 1
   else:
     while (f < 1.):
       f *= 10.
       n -= 1

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

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

 print "F (%f) = %s" % (F, S)	# dekete this in the macro

#	Some tests...

eng ()

eng (1.)
eng (1.23)
eng (123)

eng (-1.)
eng (-1.23)
eng (-123)

eng (11.)

eng (0.4)
eng (-0.4)

eng (0.004)
eng (-0.04)

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

Reply via email to