Re: Controlling number of zeros of exponent in scientific notation

2013-03-06 Thread Russ P.
One possibility is to form the string as usual, split on the "e", format each part separately, then rejoin with an "e". On Tuesday, March 5, 2013 12:09:10 PM UTC-8, fa...@squashclub.org wrote: > Instead of: > > > > 1.8e-04 > > > > I need: > > > > 1.8e-004 > > > > So two zeros before t

Re: Controlling number of zeros of exponent in scientific notation

2013-03-06 Thread jmfauth
On 6 mar, 15:03, Roy Smith wrote: > In article , > >  fa...@squashclub.org wrote: > > Instead of: > > > 1.8e-04 > > > I need: > > > 1.8e-004 > > > So two zeros before the 4, instead of the default 1. > > Just out of curiosity, what's the use case here? -- >>> from vecmat6 import * >>> from s

Re: Controlling number of zeros of exponent in scientific notation

2013-03-06 Thread Roy Smith
In article , fa...@squashclub.org wrote: > Instead of: > > 1.8e-04 > > I need: > > 1.8e-004 > > So two zeros before the 4, instead of the default 1. Just out of curiosity, what's the use case here? -- http://mail.python.org/mailman/listinfo/python-list

Re: Controlling number of zeros of exponent in scientific notation

2013-03-05 Thread Terry Reedy
On 3/5/2013 3:09 PM, fa...@squashclub.org wrote: Instead of: 1.8e-04 I need: 1.8e-004 So two zeros before the 4, instead of the default 1. The standard e and g float formats do not give you that kind of control over the exponent. You have to write code that forms the string you want. You can

Re: Controlling number of zeros of exponent in scientific notation

2013-03-05 Thread Dave Angel
On 03/05/2013 03:09 PM, fa...@squashclub.org wrote: Instead of: 1.8e-04 I need: 1.8e-004 So two zeros before the 4, instead of the default 1. You could insert a zero two characters before the end, num = "1.8e-04" num = num[:-2] + "0" + num[-2:] But to get closer to your problem, could yo

Controlling number of zeros of exponent in scientific notation

2013-03-05 Thread faraz
Instead of: 1.8e-04 I need: 1.8e-004 So two zeros before the 4, instead of the default 1. -- http://mail.python.org/mailman/listinfo/python-list