473,508 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Extreme math variables

I'm making a physics that uses very small numbers such as 9.88E-19. that is,
9.88 times 10 to the power of -19. I've run into a few problems doing
calculations with numbers like these.
the first one is that I can't figure out how to write scientific notation
which is that E that I used in the first sentence. it means to multiply by
ten to some power. I know the math.E exists but I don't know how to use it.

Maybe after I figure that first part out, I will fix my other problem
because I enter numbers in like so: 0.00000000000098. and I think the
computer records the 0.0 and that's all. instead of recording 9.8 and the
number of 0's. but the problem is that I can't use the data types double or
decimal because the compiler won't let me multiply them, which makes them
useless, and I end up losing the most important digits in these
calculations. So, is there any standard way of doing such large
calculations? Are there variables I can use like decimal and still be able
to multiply?
thanks
dave
Nov 15 '05 #1
3 3748
The "double" type should handle that scale easily.

double a = 0.00000000000098;
double b = 0.00000000000076;
double c = a * b;

This results in c=7.448E-25. What types of errors are you encountering?

Math.E is just a constant, 2.718281828459045.... It's not directly related
to the "E" in scientific notation.

"Dave" <da*********@hotmail.com> wrote in message
news:2a********************@comcast.com...
I'm making a physics that uses very small numbers such as 9.88E-19. that is, 9.88 times 10 to the power of -19. I've run into a few problems doing
calculations with numbers like these.
the first one is that I can't figure out how to write scientific notation
which is that E that I used in the first sentence. it means to multiply by ten to some power. I know the math.E exists but I don't know how to use it.
Maybe after I figure that first part out, I will fix my other problem
because I enter numbers in like so: 0.00000000000098. and I think the
computer records the 0.0 and that's all. instead of recording 9.8 and the
number of 0's. but the problem is that I can't use the data types double or decimal because the compiler won't let me multiply them, which makes them
useless, and I end up losing the most important digits in these
calculations. So, is there any standard way of doing such large
calculations? Are there variables I can use like decimal and still be able
to multiply?
thanks
dave

Nov 15 '05 #2
Tom
Sounds to me like the Decimal type would be appropriate for you. Here's an
excerpt from the documentation:

The binary representation of an instance of Decimal consists of a 1-bit
sign, a 96-bit integer number, and a scaling factor used to divide the
96-bit integer and specify what portion of it is a decimal fraction. The
scaling factor is implicitly the number 10, raised to an exponent ranging
from 0 to 28.

Therefore, the binary representation of a Decimal value is of the form,
((-296 to 2 96)/ 10 (0 to 28)), where -2 96 is equal to MinValue, and 296 is
equal to MaxValue.

Tom Clement,

Apptero, Inc.

"Dave" <da*********@hotmail.com> wrote in message
news:2a********************@comcast.com...
I'm making a physics that uses very small numbers such as 9.88E-19. that is, 9.88 times 10 to the power of -19. I've run into a few problems doing
calculations with numbers like these.
the first one is that I can't figure out how to write scientific notation
which is that E that I used in the first sentence. it means to multiply by ten to some power. I know the math.E exists but I don't know how to use it.
Maybe after I figure that first part out, I will fix my other problem
because I enter numbers in like so: 0.00000000000098. and I think the
computer records the 0.0 and that's all. instead of recording 9.8 and the
number of 0's. but the problem is that I can't use the data types double or decimal because the compiler won't let me multiply them, which makes them
useless, and I end up losing the most important digits in these
calculations. So, is there any standard way of doing such large
calculations? Are there variables I can use like decimal and still be able
to multiply?
thanks
dave

Nov 15 '05 #3
Dave,

You should be able to write constants like this:

double val = 9.88e-19;

We can probably help you better if you post some code and explain what
you're trying to do.

--
Eric Gunnerson

Visit the C# product team at http://www.csharp.net
Eric's blog is at http://blogs.gotdotnet.com/ericgu/

This posting is provided "AS IS" with no warranties, and confers no rights.
"Dave" <da*********@hotmail.com> wrote in message
news:2a********************@comcast.com...
I'm making a physics that uses very small numbers such as 9.88E-19. that is, 9.88 times 10 to the power of -19. I've run into a few problems doing
calculations with numbers like these.
the first one is that I can't figure out how to write scientific notation
which is that E that I used in the first sentence. it means to multiply by ten to some power. I know the math.E exists but I don't know how to use it.
Maybe after I figure that first part out, I will fix my other problem
because I enter numbers in like so: 0.00000000000098. and I think the
computer records the 0.0 and that's all. instead of recording 9.8 and the
number of 0's. but the problem is that I can't use the data types double or decimal because the compiler won't let me multiply them, which makes them
useless, and I end up losing the most important digits in these
calculations. So, is there any standard way of doing such large
calculations? Are there variables I can use like decimal and still be able
to multiply?
thanks
dave

Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6109
by: Murat Tasan | last post by:
here is the situation... i have an array... and i select something from random from it. i pick a random number x by using Math.random() and multiplying it by the length of the array. but this...
0
2255
by: MarionEll | last post by:
--------------------------------------------------------- ************* Call for Participation ************** ************ Late Breaking News ************* *********** Extreme...
0
1351
by: MarionEll | last post by:
--------------------------------------------------------- ************* Complete Program Available ************** ************ Late Breaking Sessions Added ************* *********** Extreme...
1
1850
by: Reiner Apke | last post by:
Hello, I have got a very strange problem with the calcualtion of the the square root (Math.Sqrt()). I calculate in a loop a lot of of diameters maxDiameter = Math.Sqrt(maxCrossSection *...
7
2586
by: Wernfried Schwenkner | last post by:
I've found the discussion about Math.Log and the error with Math.Log(8,2) on Google. Unfortunatly the full thread isn't on my news server, so I can't reply. The problem doesn't only depend...
11
7327
by: Sambo | last post by:
I have the following module: ------------------------------- import math def ac_add_a_ph( amp1, ph1, amp2, ph2 ): amp3 = 0.0 ph3 = 0.0 ac1 = ( 0, 0j ) ac2 = ( 0, 0j )
0
1050
by: Tommie Usdin | last post by:
The program for Extreme Markup Languages 2006 is now available at: http://www.extrememarkup.com/extreme/2006/e06-at-a-glance.html Topics at Extreme 2006 will range from XSLT, RDF, XPath, Ropic...
5
11262
by: matthias s | last post by:
Hi there, I believed that Math.Ceiling is like Math.Round except that it always rounds up to the next but this double d = Math.Ceiling(29/15);
17
3883
by: Lenni | last post by:
Hi, I'm currently writing a web application for bicycle wheel builders that calculate the spoke length for all sorts of variations of hubs and rims. I have translated the formula from an...
0
7225
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,...
0
7124
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7385
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...
0
7498
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...
0
5629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4707
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...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1558
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 ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.