470,614 Members | 1,548 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,614 developers. It's quick & easy.

Converting floating point to string in non-scientific format

Hi all:

When I try to convert a float variable into string via repr() or str()
function, i get the value as is, i.e '0.1e-7' in IEEE 754 format.
Instead how can force the created string to represent the floating
point in non-scientific fashion (non IEEE 754 format)? i.e
something like 0.000000001

Thanks in advance for your help.

-Madhu
May 1 '06 #1
2 3301
Madhusudhanan Chandrasekaran wrote:
Hi all:

When I try to convert a float variable into string via repr() or str()
function, i get the value as is, i.e '0.1e-7' in IEEE 754 format.
Instead how can force the created string to represent the floating
point in non-scientific fashion (non IEEE 754 format)? i.e
something like 0.000000001


Use the % operator with the f format (e.g., '%.7f' % x).

May 1 '06 #2
See also non-exponential floating point representation in
http://aspn.activestate.com/ASPN/Coo.../Recipe/358361 by R.
Hettinger.

May 1 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

24 posts views Thread by j0mbolar | last post: by
13 posts views Thread by Paraic Gallagher | last post: by
3 posts views Thread by prouleau001 | last post: by
116 posts views Thread by Dilip | last post: by
14 posts views Thread by Peter Sprenger | last post: by
10 posts views Thread by Hank Stalica | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.