RE: avoid scientific notation
- From: "Charlie" <Charlie@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 7 Jun 2005 08:29:11 -0700
ONLY 2108 digits? Are you serious? For what purpose do you need such
accuracy? Are you trying to land a rover next to a particular boulder on
Pluto?
I believe your calculation requirements are beyond the limits of the numeric
datatypes available in VB. Your method of adding the single digits of
strings makes me think there may be a way to use three arrays of longs,
making sure each element stays in the range -999999999 to 999999999 and
keeping track of carrying the one to successive elements. Then format the
elements of the resultant (third) array to strings and append them together.
Might be faster than doing individual digits.
000066000 010000009 900000000
123456789 989999990 900000001
----------------------------------------
123522790 000000000 800000001
For i = 1 To nElements
strResult = strResult & Format(lngResult(i), "000000000")
Next i
"123522790000000000800000001"
"Tom F" wrote:
> I am trying to add some large numbers (between 10^15 and 10^300) and want to
> know the exact values. When VB starts adding the values at that range it
> defaults to using scientific notation. The only solution I've come up with is
> to save the numbers as strings, have VB add each digit, and dump that into
> another string. That works but is slow and resource intensive. To test it I
> calculated 2^x up to x=7000. It took a 2ghz laptop about an hour to get that
> far using that technique and it is only 2108 digits.
>
> Anyway, my question is: Is there a way to tell VB to format to standard
> notation?
.
- Follow-Ups:
- RE: avoid scientific notation
- From: Tom F
- Re: avoid scientific notation
- From: Jeff Johnson [MVP: VB]
- RE: avoid scientific notation
- References:
- avoid scientific notation
- From: Tom F
- avoid scientific notation
- Prev by Date: Re: XML Parser
- Next by Date: Re: avoid scientific notation
- Previous by thread: Re: avoid scientific notation
- Next by thread: Re: avoid scientific notation
- Index(es):
Relevant Pages
|