Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Very Large Number Calculations

Status
Not open for further replies.

chrisw669

Technical User
Feb 19, 2002
43
0
0
US
I am trying to divide 2 very large numbers and keep getting the 9999999E+23 type output. What is the limit of int, double? I've tried both and can only goto 15 digits on double. Honestly I need to goto as big as 45 digits.

Here's an example....

897234872309472894706472634798 / 234982304 =

3.81830825996784E+21

Is this even possible in asp or is there another way to pull off very large numbers?

Thanks
 
Byte Contains integer in the range 0 to 255.

Integer Contains integer in the range -32,768 to 32,767.

Currency -922,337,203,685,477.5808 to 922,337,203,685,477.5807.

Long Contains integer in the range -2,147,483,648 to 2,147,483,647.

Single Contains a single-precision, floating-point number in the range -3.402823E38 to -1.401298E-45 for negative values; 1.401298E-45 to 3.402823E38 for positive values.

Double Contains a double-precision, floating-point number in the range -1.79769313486232E308 to -4.94065645841247E-324 for negative values; 4.94065645841247E-324 to 1.79769313486232E308 for positive values.
 
In ASP everything is really a Variant datatype. Variant has subtypes that determine what kind of data the Variant holds, but it doesn't change the way the data is stored, per se.

The double datatype that Variant can "pretend" to be can handle negative numbers from -1.79769313486232E308 to -4.94065645841247E-324, and positive numbers from 4.904065645841247E-324 to 1379769313486232E308. That's 308 to 324 digits, so it should be able to do the math just fine.

However the problem I think you're running into is the display of the result: I don't think it's capable of displaying the result as non-scientifically (with the E) if it's larger than a Long, which is only 10 digits.
 
Oops, change the parenthetical comment of my last sentence to:
(without the E)
:)
 
d = 897234872309472894706472634798897234872309472894706472634798 / 234982304
Response.Write(FormatNumber(d, 4))

and I got
3,818,308,259,967,840,000,000,000,000,000,000,000,000,000,000,000,000.0000

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top