473,513 Members | 4,001 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Scientific Notation

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
7 10883
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
No, I mean given a big number, such as
10000000000000000000000000000000000000000000000000 00, convert it into
scientific notation.

Dec 4 '05 #3
In article <11*********************@g14g2000cwa.googlegroups. com>,
"Dustan" <Du**********@gmail.com> wrote:
10000000000000000000000000000000000000000000000000 00

print "%e" % 10000000000000000000000000000000000000000000000000 00

1.000000e+51
Dec 4 '05 #4
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
"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
> > > 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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
8696
by: Woodster | last post by:
I am using the std::setprecision function to format variables of type double in a string however I am unsure how to stop this appearing in scientific notation. For example std::stringstream buffer; buffer << setprecision(1) << 40.0 << "° C";
1
2022
by: masoud bayan | last post by:
I have some values in type of double such 0.00009 , 0.0000007, when I want to show them in a text box and convert them to string they are changed to scientific notation while I want to show them as they are. I tried to use tostring("f") but it needs to have a precision number after *f* which will cause always have fix number of characters...
1
8804
by: Nick | last post by:
Well, the project I am working on has now come to a screeching halt! I have been developing a program that heavily utilizes ADO.NET record sets. To generate reports, I convert the recordset to XML, and then apply an XSLT to transform the XML into HTML. This works great (or did) until today. I just found out that the "number-format" command in...
0
1678
by: Greg | last post by:
I am working on an application that requires working with numbers in scientific notation. I am using SqlServer as the database and I have created strongly typed data adapters and datasets. The numbers are defined as numeric in the SqlServer Database and are bound to text boxes in the app. In the dataset xml these numbers are defined as...
2
7243
by: Ryan Liu | last post by:
In C#, for a large float (9 digitals), how can I disable Scientific notation. When it auto convert to Scientific notation, I lost accuracy. Thanks a lot! Ryan
9
6612
by: Joe Attardi | last post by:
Hi all, Math is not my strongest area so forgive me if I use some of the wrong terminology. It seems that scientific notation is immune to rounding errors. For example: (4.98 * 100) + 5.51 // returns 503.51000000000005, rounding error! 4.98e2 + 5.51 // returns 503.51, correct!
2
2749
by: rSmoke | last post by:
I have a DataSet that contains a table with about 6 columns of high accuracy decimal values. When I try to write out the DataSet using the WriteXML() function the XML is written fine, but the decimal values are written out in scientific notation ("9.984348392E+08"). This wouldn't be a problem except when I try to READ the XML file back into a...
7
2121
by: grinder | last post by:
I have a program that fits a line to data points. The question is: can 'C' understand scientific notation (as below) , and if not what can i do to make it work.. 0.000 0.3231E+02 0.0000E+00 0.00 0.5642E+02 13.191 0.3421E+02 0.0000E+00 10.00 0.5910E+02 26.248 0.2842E+02 0.0000E+00 20.00 0.4758E+02
2
6992
by: Greg | last post by:
I am working on an application that requires working with numbers in scientific notation. I am using SqlServer as the database and I have created strongly typed data adapters and datasets. The numbers are defined as numeric in the SqlServer Database and are bound to text boxes in the app. In the dataset's xml these numbers are defined as...
0
7270
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7563
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7125
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7543
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5102
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4757
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3252
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3239
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.