Controlling number of zeros of exponent in scientific notation

jmfauth wxjmfauth at gmail.com
Wed Mar 6 10:16:16 EST 2013


On 6 mar, 15:03, Roy Smith <r... at panix.com> wrote:
> In article <c2184b42-41be-4930-9501-361296df7679 at googlegroups.com>,
>
>  fa... at 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 svdecomp6 import *
>>> from vmio6 import *
>>> mm = NewMat(3, 2)
>>> mm[0][0] = 1.0; mm[0][1] = 2.0e-178
>>> mm[1][0] = 3.0; mm[1][1] = 4.0e-1428
>>> mm[2][0] = 5.0; mm[2][1] = 6.0
>>> pr(mm, 'mm =')
mm =
(   1.00000e+000  2.00000e-178 )
(   3.00000e+000  0.00000e+000 )
(   5.00000e+000  6.00000e+000 )
>>> aa, vv, bbt = SVDecompFull(mm)
>>> pr(aa, 'aa =')
aa =
(   3.04128e-001 -8.66366e-002 )
(   9.12385e-001 -2.59910e-001 )
(  -2.73969e-001 -9.61739e-001 )
>>> pr(bbt, 'bbt =')
bbt =
(   7.12974e-001 -7.01190e-001 )
(  -7.01190e-001 -7.12974e-001 )
>>> rr = MatMulMatMulMat(aa, vv, bbt)
>>> pr(rr, 'rr =')
rr =
(   1.00000e+000 -1.38778e-015 )
(   3.00000e+000 -4.44089e-016 )
(   5.00000e+000  6.00000e+000 )
>>>

jmf




More information about the Python-list mailing list