getting rid of leading zeros in float expotential

Discussion in 'Python' started by tom@finland.com, Jun 3, 2007.

  1. Guest

    Hi! I'm wondering whether there's an easy way to remove unnecessary
    leading zeros from my floating point number.

    realS = float(-1.25e-5)
    imgS = float(-7.6e4)

    print complex(realS, imgS)

    >> (-1.25e-005-76000j)


    I would like it to look like (-1.25e-5-76000j)
    , Jun 3, 2007
    #1
    1. Advertising

  2. Guest

    On 3 , 11:47, wrote:
    > Hi! I'm wondering whether there's an easy way to remove unnecessary
    > leading zeros from my floating point number.
    >
    > realS = float(-1.25e-5)
    > imgS = float(-7.6e4)
    >
    > print complex(realS, imgS)
    >
    > >> (-1.25e-005-76000j)

    >
    > I would like it to look like (-1.25e-5-76000j)


    why?
    For printing?
    try to process it as a string

    >>>def my_func(a):

    return my_del_zeros_func(str(a))
    , Jun 3, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dmitry Bond.

    Hexadecimal formatting with leading zeros?!

    Dmitry Bond., Oct 13, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    7,999
    Oliver Sturm
    Oct 13, 2005
  2. Luke Zhang [MSFT]

    Re: CSV for Excel - Problem with Leading Zeros

    Luke Zhang [MSFT], Jun 26, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    2,242
    Luke Zhang [MSFT]
    Jun 26, 2003
  3. GIMME
    Replies:
    5
    Views:
    43,715
    Dale King
    Feb 13, 2004
  4. bd
    Replies:
    0
    Views:
    621
  5. Carsten Fuchs
    Replies:
    45
    Views:
    1,535
    James Kanze
    Oct 8, 2009
Loading...

Share This Page