By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,621 Members | 1,101 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,621 IT Pros & Developers. It's quick & easy.

getting rid of leading zeros in float expotential

P: n/a
tom
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 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 3 , 11:47, t...@finland.com 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 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.