Converting floating point to string in non-scientific format

  • Thread starter Madhusudhanan Chandrasekaran
  • Start date
M

Madhusudhanan Chandrasekaran

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
 
D

Dan Bishop

Madhusudhanan said:
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).
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top