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

Scientific Notation

P: n/a
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.

Dec 4 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Dustan <Du**********@gmail.com> wrote:
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:
print '%e' % (1e50)

1.000000e+50

....?
Alex
Dec 4 '05 #2

P: n/a
No, I mean given a big number, such as
10000000000000000000000000000000000000000000000000 00, convert it into
scientific notation.

Dec 4 '05 #3

P: n/a
In article <11*********************@g14g2000cwa.googlegroups. com>,
"Dustan" <Du**********@gmail.com> wrote:
10000000000000000000000000000000000000000000000000 00

print "%e" % 10000000000000000000000000000000000000000000000000 00

1.000000e+51
Dec 4 '05 #4

P: n/a
Roy Smith <ro*@panix.com> wrote:
In article <11*********************@g14g2000cwa.googlegroups. com>,
"Dustan" <Du**********@gmail.com> wrote:
10000000000000000000000000000000000000000000000000 00

print "%e" % 10000000000000000000000000000000000000000000000000 00 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:
print '%g' % 10**5 100000 print '%g' % 10**50

1e+50
Alex
Dec 4 '05 #5

P: n/a
"Dustan" <Du**********@gmail.com> writes:
No, I mean given a big number, such as
10000000000000000000000000000000000000000000000000 00, convert it into
scientific notation.


It's the same.
print "%e" % 10000000000000000000000000000000000000000000000000 00

1.000000e+51
--
Jorge Godoy <go***@ieee.org>
Dec 4 '05 #6

P: n/a
> > > You mean something like:

>>> print '%e' % (1e50)
1.000000e+50

...?
No, I mean given a big number, such as
10000000000000000000000000000000000000000000000000 00, convert it into
scientific notation.


It's the same.
print "%e" % 10000000000000000000000000000000000000000000000000 00

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>

Dec 4 '05 #7

P: n/a
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.

Dec 4 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.