Scientific Notation

D

Dustan

How can I get a number into scientific notation? I have a preference
for the format '1 E 50' (as an example), but if it's well known, it
works.
 
A

Alex Martelli

Dustan said:
How can I get a number into scientific notation? I have a preference
for the format '1 E 50' (as an example), but if it's well known, it
works.

You mean something like:
1.000000e+50

....?


Alex
 
D

Dustan

No, I mean given a big number, such as
1000000000000000000000000000000000000000000000000000, convert it into
scientific notation.
 
J

Jorge Godoy

Dustan said:
No, I mean given a big number, such as
1000000000000000000000000000000000000000000000000000, convert it into
scientific notation.

It's the same.
1.000000e+51
 
A

Alex Martelli

Roy Smith said:
1.000000e+51

Exactly: the "%e" builds a ``scientific-notation" string from whatever
number you're formatting that way (big or small). You can also use %g
if what you want is fixed-point notation within a certain range and
scientific notations only for numbers OUTSIDE that range, as in:
1e+50


Alex
 
F

Fredrik Lundh

You mean something like:
It's the same.

1.000000e+51

one would have assumed that someone who *prefers* to use scientific notation
for large numbers would in fact know that, but the usenet never ceases to sur-
prise me...

</F>
 
D

Dustan

Thanks for your help, Alex, Roy and Jorge. I'm new to Python, and
programming in general, which might explain my lack of knowledge,
Fredrick.
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top