Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > getting rid of leading zeros in float expotential

Reply
Thread Tools

getting rid of leading zeros in float expotential

 
 
tom@finland.com
Guest
Posts: n/a
 
      06-03-2007
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)
 
Reply With Quote
 
 
 
 
Stebanoid@gmail.com
Guest
Posts: n/a
 
      06-03-2007
On 3 , 11:47, (E-Mail Removed) 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))

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
float to string to float, with first float == second float Carsten Fuchs C++ 45 10-08-2009 09:47 AM
Hexadecimal formatting with leading zeros?! Dmitry Bond. ASP .Net 1 10-13-2005 08:55 AM
Formatting an integer with leading zeros GIMME Java 5 02-13-2004 05:01 PM
Re: float->byte->float is same with original float image. why float->ubyte->float is different??? bd C Programming 0 07-07-2003 12:09 AM
Re: CSV for Excel - Problem with Leading Zeros Luke Zhang [MSFT] ASP .Net 0 06-26-2003 01:34 PM



Advertisments