Home All Groups Group Topic Archive Search About

Calculations on LARGE numbers



Author
13 Mar 2006 3:12 PM
Frinton
Hi,

I am trying to do some calculations on large numbers (ie
7,768,489,957,892,578,474,792,094 / 12,280) and no matter what I do it
doesn't get it quite right. Its always somewhere between 10 and and 5000 out
:(

I have a suspition is could be down to one of the number functions I am
using along the way but im not sure.

Any help or guidance would be greatly appriciated.

Thanks in advance

Fred

Author
13 Mar 2006 3:34 PM
Richard Mueller
Fred wrote:

> I am trying to do some calculations on large numbers (ie
> 7,768,489,957,892,578,474,792,094 / 12,280) and no matter what I do it
> doesn't get it quite right. Its always somewhere between 10 and and 5000
> out :(
>
> I have a suspition is could be down to one of the number functions I am
> using along the way but im not sure.
>
> Any help or guidance would be greatly appriciated.

VB and VBScript integers are Long datatypes (32-bit) and range
from -2,147,483,648 to 2,147,483,647, which is -2^31 to 2^31-1. Larger
values are handled as Float datatype which is 64-bit. Your large number is
stored as an approximation.

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
Author
13 Mar 2006 4:56 PM
Frinton
Thanks for the reply

Is there any work around to this?

Im storing the values in SQL, is BigInt the largest exact number possible?

Thanks

Fred

Show quote
"Richard Mueller" <rlmueller-NOSPAM@ameritech.NOSPAM.net> wrote in message
news:uAuQROrRGHA.1780@TK2MSFTNGP12.phx.gbl...
> Fred wrote:
>
>> I am trying to do some calculations on large numbers (ie
>> 7,768,489,957,892,578,474,792,094 / 12,280) and no matter what I do it
>> doesn't get it quite right. Its always somewhere between 10 and and 5000
>> out :(
>>
>> I have a suspition is could be down to one of the number functions I am
>> using along the way but im not sure.
>>
>> Any help or guidance would be greatly appriciated.
>
> VB and VBScript integers are Long datatypes (32-bit) and range
> from -2,147,483,648 to 2,147,483,647, which is -2^31 to 2^31-1. Larger
> values are handled as Float datatype which is 64-bit. Your large number is
> stored as an approximation.
>
> --
> Richard
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net
>
Author
13 Mar 2006 6:14 PM
Richard Mueller
Hi,

As I recall BigInt is 64-bit, but valid values range from -2^63
(-9,223,372,036,854,775,808) through 2^63-1 (9,223,372,036,854,775,807).
VB.NET can handle values in this range, but VB6 and VBScript cannot. In VB6
I've used Currency datatypes to handle large numbers. VB6 Currency values
are 64-bit scaled integers (4 digits past the decimal, saved internally as
an integer), so the maximum value is 922,337,203,685,477.5807. I'm not sure
about VBScript currency values. I've also written my own functions to do
math by breaking the value up into parts, like two 31-bit values (high and
low parts). However, my functions multiplied numbers. I remember having to
code my own CInt Function because the VB function bombs out at 2^15.
Division seems harder.

Your value is 7.77 x 10^24, which would require an 84-bit register. You
could represent it as two 42-bit numbers. However, even the 42-bit values
are too large for VB6 or VBScript. That leaves you with representing the
value as 3 30-bit numbers.

x = a * 2^60 + b * 2^30 + c

That would be a lot of work.

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net

Show quote
"Frinton" <fred_n***@hotmail.com> wrote in message
news:4415a442@212.67.96.135...
> Thanks for the reply
>
> Is there any work around to this?
>
> Im storing the values in SQL, is BigInt the largest exact number possible?
>
> Thanks
>
> Fred
>
> "Richard Mueller" <rlmueller-NOSPAM@ameritech.NOSPAM.net> wrote in message
> news:uAuQROrRGHA.1780@TK2MSFTNGP12.phx.gbl...
>> Fred wrote:
>>
>>> I am trying to do some calculations on large numbers (ie
>>> 7,768,489,957,892,578,474,792,094 / 12,280) and no matter what I do it
>>> doesn't get it quite right. Its always somewhere between 10 and and 5000
>>> out :(
>>>
>>> I have a suspition is could be down to one of the number functions I am
>>> using along the way but im not sure.
>>>
>>> Any help or guidance would be greatly appriciated.
>>
>> VB and VBScript integers are Long datatypes (32-bit) and range
>> from -2,147,483,648 to 2,147,483,647, which is -2^31 to 2^31-1. Larger
>> values are handled as Float datatype which is 64-bit. Your large number
>> is stored as an approximation.
>>
>> --
>> Richard
>> Microsoft MVP Scripting and ADSI
>> Hilltop Lab - http://www.rlmueller.net
>>
>
>
Author
13 Mar 2006 11:50 PM
Richard Mueller
I find that VBScript can represent 2^48 and 2^49 exactly, but not 2^50.

I see no way to even break up your number into high and low parts, much less
do math with them. For example, if I attempt to represent your large number
as:

x = a * (2^42) + b

I can possibly find a, but not b.

a = IntegerPart(x/(2^42))

where IntegerPart must be coded, since CInt has no chance of working. Then

b = x - a * (2^42)

but VBScript cannot represent a * (2^42) exactly, so b is wrong. I see no
chance of doing long division if I cannot even break up the number as above.
VBScript cannot do any math exactly where any intermediate value is greater
than about 2^48.

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net

Show quote
"Richard Mueller" <rlmueller-NOSPAM@ameritech.NOSPAM.net> wrote in message
news:%23i3DvnsRGHA.1688@TK2MSFTNGP11.phx.gbl...
> Hi,
>
> As I recall BigInt is 64-bit, but valid values range from -2^63
> (-9,223,372,036,854,775,808) through 2^63-1 (9,223,372,036,854,775,807).
> VB.NET can handle values in this range, but VB6 and VBScript cannot. In
> VB6 I've used Currency datatypes to handle large numbers. VB6 Currency
> values are 64-bit scaled integers (4 digits past the decimal, saved
> internally as an integer), so the maximum value is
> 922,337,203,685,477.5807. I'm not sure about VBScript currency values.
> I've also written my own functions to do math by breaking the value up
> into parts, like two 31-bit values (high and low parts). However, my
> functions multiplied numbers. I remember having to code my own CInt
> Function because the VB function bombs out at 2^15. Division seems harder.
>
> Your value is 7.77 x 10^24, which would require an 84-bit register. You
> could represent it as two 42-bit numbers. However, even the 42-bit values
> are too large for VB6 or VBScript. That leaves you with representing the
> value as 3 30-bit numbers.
>
> x = a * 2^60 + b * 2^30 + c
>
> That would be a lot of work.
>
> --
> Richard
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net
>
> "Frinton" <fred_n***@hotmail.com> wrote in message
> news:4415a442@212.67.96.135...
>> Thanks for the reply
>>
>> Is there any work around to this?
>>
>> Im storing the values in SQL, is BigInt the largest exact number
>> possible?
>>
>> Thanks
>>
>> Fred
>>
>> "Richard Mueller" <rlmueller-NOSPAM@ameritech.NOSPAM.net> wrote in
>> message news:uAuQROrRGHA.1780@TK2MSFTNGP12.phx.gbl...
>>> Fred wrote:
>>>
>>>> I am trying to do some calculations on large numbers (ie
>>>> 7,768,489,957,892,578,474,792,094 / 12,280) and no matter what I do it
>>>> doesn't get it quite right. Its always somewhere between 10 and and
>>>> 5000 out :(
>>>>
>>>> I have a suspition is could be down to one of the number functions I am
>>>> using along the way but im not sure.
>>>>
>>>> Any help or guidance would be greatly appriciated.
>>>
>>> VB and VBScript integers are Long datatypes (32-bit) and range
>>> from -2,147,483,648 to 2,147,483,647, which is -2^31 to 2^31-1. Larger
>>> values are handled as Float datatype which is 64-bit. Your large number
>>> is stored as an approximation.
>>>
>>> --
>>> Richard
>>> Microsoft MVP Scripting and ADSI
>>> Hilltop Lab - http://www.rlmueller.net
>>>
>>
>>
>
>
Author
14 Mar 2006 2:12 PM
Dave Anderson
Richard Mueller wrote:
> I find that VBScript can represent 2^48 and 2^49 exactly,
> but not 2^50.

That depends on what you mean by "represent". Consider:

p = 2^53

For i=-10 To 10
    Response.Write(Represent(p+i) & "<br>")
Next

Function Represent(N)
    M = Int(N/1000)
    R = N - 1000*M
    If (M = 0) Then
        Represent = R
    Else
        Represent = Represent(M) & "," & Right("00" & R,3)
    End If
End Function

[Disclaimer: only "works" with positive integers]

I chose 2^53 for a reason. VBScript can distinguish between individual
integers up through 2^53. Above 2^53, numbers are spaced by 2. Above 2^54,
they are spaced by 4. Above 2^55, by 8. I'll let you work out the sequence
above that.


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Author
14 Mar 2006 11:19 PM
Dr John Stockton
JRS:  In article <et34ujvRGHA.1***@TK2MSFTNGP12.phx.gbl>, dated Mon, 13
Mar 2006 17:50:35 remote, seen in news:microsoft.public.scripting.vbscri
pt, Richard Mueller <rlmueller-NOSPAM@ameritech.NOSPAM.net> posted :
Show quote
>I find that VBScript can represent 2^48 and 2^49 exactly, but not 2^50.
>
>I see no way to even break up your number into high and low parts, much less
>do math with them. For example, if I attempt to represent your large number
>as:
>
>x = a * (2^42) + b
>
>I can possibly find a, but not b.
>
>a = IntegerPart(x/(2^42))
>
>where IntegerPart must be coded, since CInt has no chance of working. Then
>
>b = x - a * (2^42)
>
>but VBScript cannot represent a * (2^42) exactly, so b is wrong. I see no
>chance of doing long division if I cannot even break up the number as above.
>VBScript cannot do any math exactly where any intermediate value is greater
>than about 2^48.


Eschew excessive quotation.


You have not thought the matter through sufficiently.

Clearly, given a need to calculate 123456789 * 987654321, one can break
those numbers into their individual digits, and long-multiply them as
you should have been taught at school.  My longcalc.pas does that, using
digits base 2..16.

One can also split them as 123 456 789 * 987 654 321, effectively base
1000, to do the job quicker.  AIUI, ordinary integers in VBscript are
held in IEEE Doubles, so that one could work to base 2^26 with digit-
products up to 2^52.  Base 1000000 easily fits.

The large numbers cannot, of course, be supplied accurately as
individual VBS numbers; strings or arrays are needed.

There's a trick for speeding multiplication of large numbers; it's in
ALGORITHMICS by Brassard & Bratley, ISBN 0-13-023169-X


--
© John Stockton, Surrey, UK.  ?@merlyn.demon.co.uk   Delphi 3   Turnpike 4 ©
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
<URL:http://www.bancoems.com/CompLangPascalDelphiMisc-MiniFAQ.htm> clpdmFAQ;
<URL:http://www.borland.com/newsgroups/guide.html> news:borland.* Guidelines
Author
15 Mar 2006 2:03 AM
Richard Mueller
Show quote
"Dr John Stockton" <j**@merlyn.demon.co.uk> wrote in message
news:Rdfor9BB+0FEFwBd@merlyn.demon.co.uk...
> JRS:  In article <et34ujvRGHA.1***@TK2MSFTNGP12.phx.gbl>, dated Mon, 13
> Mar 2006 17:50:35 remote, seen in news:microsoft.public.scripting.vbscri
> pt, Richard Mueller <rlmueller-NOSPAM@ameritech.NOSPAM.net> posted :
>>I find that VBScript can represent 2^48 and 2^49 exactly, but not 2^50.
>>
>>I see no way to even break up your number into high and low parts, much
>>less
>>do math with them. For example, if I attempt to represent your large
>>number
>>as:
>>
>>x = a * (2^42) + b
>>
>>I can possibly find a, but not b.
>>
>>a = IntegerPart(x/(2^42))
>>
>>where IntegerPart must be coded, since CInt has no chance of working. Then
>>
>>b = x - a * (2^42)
>>
>>but VBScript cannot represent a * (2^42) exactly, so b is wrong. I see no
>>chance of doing long division if I cannot even break up the number as
>>above.
>>VBScript cannot do any math exactly where any intermediate value is
>>greater
>>than about 2^48.
>
>
> Eschew excessive quotation.
>
>
> You have not thought the matter through sufficiently.
>
> Clearly, given a need to calculate 123456789 * 987654321, one can break
> those numbers into their individual digits, and long-multiply them as
> you should have been taught at school.  My longcalc.pas does that, using
> digits base 2..16.
>
> One can also split them as 123 456 789 * 987 654 321, effectively base
> 1000, to do the job quicker.  AIUI, ordinary integers in VBscript are
> held in IEEE Doubles, so that one could work to base 2^26 with digit-
> products up to 2^52.  Base 1000000 easily fits.
>
> The large numbers cannot, of course, be supplied accurately as
> individual VBS numbers; strings or arrays are needed.
>
> There's a trick for speeding multiplication of large numbers; it's in
> ALGORITHMICS by Brassard & Bratley, ISBN 0-13-023169-X
>
>
> --
> © John Stockton, Surrey, UK.  ?@merlyn.demon.co.uk   Delphi 3   Turnpike 4
> ©
> <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics &
> links;
> <URL:http://www.bancoems.com/CompLangPascalDelphiMisc-MiniFAQ.htm>
> clpdmFAQ;
> <URL:http://www.borland.com/newsgroups/guide.html> news:borland.*
> Guidelines

John,

I was saying I couldn't work it out breaking the number up into high and low
2^42 parts. I think you are correct that each "digit" must be 2^26. That is,
the number must be broken up into 26 bit parts (or less). In the poster's
example, it cannot be done in 2 parts or even 3. The big number would have
to be broken up into 4 26-bit parts. Rather than inventing that wheel, I'd
suggest your program.

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
Author
13 Mar 2006 3:46 PM
Egbert Nierop (MVP for IIS)
"Frinton" <fred_n***@hotmail.com> wrote in message
news:44158bca@212.67.96.135...
> Hi,
>
> I am trying to do some calculations on large numbers (ie
> 7,768,489,957,892,578,474,792,094 / 12,280) and no matter what I do it
> doesn't get it quite right. Its always somewhere between 10 and and 5000
> out :(

The best is to convert it to currency.
dim v
v=CCur(10)
v=v * ccur(103030303030.1034)

Show quote
> I have a suspition is could be down to one of the number functions I am
> using along the way but im not sure.
Author
13 Mar 2006 4:57 PM
Frinton
Thanks for the reply

Im getting an overflow when I try this :(

Fred

Show quote
"Egbert Nierop (MVP for IIS)" <egbert_nierop@nospam.invalid> wrote in
message news:uJdVPVrRGHA.2156@tk2msftngp13.phx.gbl...
>
> "Frinton" <fred_n***@hotmail.com> wrote in message
> news:44158bca@212.67.96.135...
>> Hi,
>>
>> I am trying to do some calculations on large numbers (ie
>> 7,768,489,957,892,578,474,792,094 / 12,280) and no matter what I do it
>> doesn't get it quite right. Its always somewhere between 10 and and 5000
>> out :(
>
> The best is to convert it to currency.
> dim v
> v=CCur(10)
> v=v * ccur(103030303030.1034)
>
>> I have a suspition is could be down to one of the number functions I am
>> using along the way but im not sure.
>
Author
14 Mar 2006 7:44 AM
Egbert Nierop (MVP for IIS)
"Frinton" <fred_n***@hotmail.com> wrote in message
news:4415a490@212.67.96.135...
> Thanks for the reply
>
> Im getting an overflow when I try this :(

sad.

More sadness :)

The OLEautomation runtime Oleaut32.dll supports 8 byte integers (V_I8), they
should be called 'very long' or so...
But vbscript has been feature-frozen, so it does not match the current OS
when we think about calculation.

You might try vbscript.net that -has- support for 8 byte calculations.

Show quote
> Fred
Author
13 Mar 2006 4:31 PM
Evertjan.
Frinton wrote on 13 mrt 2006 in microsoft.public.inetserver.asp.general:

> I am trying to do some calculations on large numbers (ie
> 7,768,489,957,892,578,474,792,094 / 12,280) and no matter what I do it
> doesn't get it quite right. Its always somewhere between 10 and and
> 5000 out
> :(
>
> I have a suspition is could be down to one of the number functions I
> am using along the way but im not sure.
>
> Any help or guidance would be greatly appriciated.

<http://en.wikipedia.org/wiki/Long_division>


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Author
13 Mar 2006 4:58 PM
Frinton
Thanks for the reply

Its not the calculation that is causing me the problem its the storing of
values

Fred

Show quote
"Evertjan." <exjxw.hannivo***@interxnl.net> wrote in message
news:Xns9785B2358D898eejj99@194.109.133.242...
> Frinton wrote on 13 mrt 2006 in microsoft.public.inetserver.asp.general:
>
>> I am trying to do some calculations on large numbers (ie
>> 7,768,489,957,892,578,474,792,094 / 12,280) and no matter what I do it
>> doesn't get it quite right. Its always somewhere between 10 and and
>> 5000 out
>> :(
>>
>> I have a suspition is could be down to one of the number functions I
>> am using along the way but im not sure.
>>
>> Any help or guidance would be greatly appriciated.
>
> <http://en.wikipedia.org/wiki/Long_division>
>
>
> --
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)
Author
13 Mar 2006 5:20 PM
Tim Slattery
"Frinton" <fred_n***@hotmail.com> wrote:

>Thanks for the reply
>
>Its not the calculation that is causing me the problem its the storing of
>values

In VB or VBScript there's probably no way out of this. Java (not
JavaScript) has a BigInteger class, and there are classes available
for C++ that can handle integers of arbitrary precision.

Arithmetic operations in these classes would not be fast, but they
would preserve and use the full precision.

--
Tim Slattery
MS MVP(DTS)
Slatter***@bls.gov
Author
13 Mar 2006 6:43 PM
Evertjan.
Frinton wrote on 13 mrt 2006 in microsoft.public.inetserver.asp.general:
Show quote
> "Evertjan." <exjxw.hannivo***@interxnl.net> wrote in message
> news:Xns9785B2358D898eejj99@194.109.133.242...
>> Frinton wrote on 13 mrt 2006 in
>> microsoft.public.inetserver.asp.general:
>>
>>> I am trying to do some calculations on large numbers (ie
>>> 7,768,489,957,892,578,474,792,094 / 12,280) and no matter what I do
>>> it doesn't get it quite right. Its always somewhere between 10 and
>>> and 5000 out
>>> :(
>>>
>>> I have a suspition is could be down to one of the number functions I
>>> am using along the way but im not sure.
>>>
>>> Any help or guidance would be greatly appriciated.
>>
>> <http://en.wikipedia.org/wiki/Long_division>

[please do not toppost on usenet]


> Thanks for the reply
>
> Its not the calculation that is causing me the problem its the storing
> of values

That is no problem, you can store them as a string.

In fact, you do the long division also with string parts.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Author
13 Mar 2006 5:30 PM
Jerold Schulman
Show quote
On Mon, 13 Mar 2006 15:12:09 -0000, "Frinton" <fred_n***@hotmail.com> wrote:

>Hi,
>
>I am trying to do some calculations on large numbers (ie
>7,768,489,957,892,578,474,792,094 / 12,280) and no matter what I do it
>doesn't get it quite right. Its always somewhere between 10 and and 5000 out
>:(
>
>I have a suspition is could be down to one of the number functions I am
>using along the way but im not sure.
>
>Any help or guidance would be greatly appriciated.
>
>Thanks in advance
>
>Fred
>
See tip 4533 » How do I perform accurate and/or complex math in a batch? 11-Dec-01
in the 'Tips & Tricks' at http://www.jsifaq.com

When I type the following at a CMD.EXE prompt:
for /f %i in ('domath //nologo "Round(7768489957892578474792094/12280)"') do @echo %i

I get 6.32613188753467E+20




Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com
Author
13 Mar 2006 5:54 PM
Frinton
Show quote
"Jerold Schulman" <Je***@jsiinc.com> wrote in message
news:lvab12hhot3fte9q60vb1qgcbvhp6h9q24@4ax.com...
> On Mon, 13 Mar 2006 15:12:09 -0000, "Frinton" <fred_n***@hotmail.com>
> wrote:
>
>>Hi,
>>
>>I am trying to do some calculations on large numbers (ie
>>7,768,489,957,892,578,474,792,094 / 12,280) and no matter what I do it
>>doesn't get it quite right. Its always somewhere between 10 and and 5000
>>out
>>:(
>>
>>I have a suspition is could be down to one of the number functions I am
>>using along the way but im not sure.
>>
>>Any help or guidance would be greatly appriciated.
>>
>>Thanks in advance
>>
>>Fred
>>
> See tip 4533 » How do I perform accurate and/or complex math in a batch?
> 11-Dec-01
> in the 'Tips & Tricks' at http://www.jsifaq.com
>
> When I type the following at a CMD.EXE prompt:
> for /f %i in ('domath //nologo "Round(7768489957892578474792094/12280)"')
> do @echo %i
>
> I get 6.32613188753467E+20
>
>
>
>
> Jerold Schulman
> Windows Server MVP
> JSI, Inc.
> http://www.jsiinc.com
> http://www.jsifaq.com
Author
13 Mar 2006 5:59 PM
Frinton
Thanks for the reply

The trouble is when I format this result into a "readable" number (using
vbscripts FormatNumber function) it comes out as 632,613,188,753,467,000,000

The true answer and the one im looking for is

632,613,188,753,467,302,507

Regards

Fred





Show quote
"Jerold Schulman" <Je***@jsiinc.com> wrote in message
news:lvab12hhot3fte9q60vb1qgcbvhp6h9q24@4ax.com...
> On Mon, 13 Mar 2006 15:12:09 -0000, "Frinton" <fred_n***@hotmail.com>
> wrote:
>
>>Hi,
>>
>>I am trying to do some calculations on large numbers (ie
>>7,768,489,957,892,578,474,792,094 / 12,280) and no matter what I do it
>>doesn't get it quite right. Its always somewhere between 10 and and 5000
>>out
>>:(
>>
>>I have a suspition is could be down to one of the number functions I am
>>using along the way but im not sure.
>>
>>Any help or guidance would be greatly appriciated.
>>
>>Thanks in advance
>>
>>Fred
>>
> See tip 4533 » How do I perform accurate and/or complex math in a batch?
> 11-Dec-01
> in the 'Tips & Tricks' at http://www.jsifaq.com
>
> When I type the following at a CMD.EXE prompt:
> for /f %i in ('domath //nologo "Round(7768489957892578474792094/12280)"')
> do @echo %i
>
> I get 6.32613188753467E+20
>
>
>
>
> Jerold Schulman
> Windows Server MVP
> JSI, Inc.
> http://www.jsiinc.com
> http://www.jsifaq.com
Author
13 Mar 2006 6:41 PM
Richard Mueller
I wonder if that confirms that the value was handled internally as a
currency, a scaled 64-bit integer. I note that I get the same answer if I
omit the Round function. I used the following VBScript program:

x= Eval("(7768489957892578474792094/12280)")

Wscript.Echo FormatNumber(x, 4)

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net

Show quote
"Frinton" <fred_n***@hotmail.com> wrote in message
news:4415b30c@212.67.96.135...
> Thanks for the reply
>
> The trouble is when I format this result into a "readable" number (using
> vbscripts FormatNumber function) it comes out as
> 632,613,188,753,467,000,000
>
> The true answer and the one im looking for is
>
> 632,613,188,753,467,302,507
>
> Regards
>
> Fred
>
>
>
>
>
> "Jerold Schulman" <Je***@jsiinc.com> wrote in message
> news:lvab12hhot3fte9q60vb1qgcbvhp6h9q24@4ax.com...
>> On Mon, 13 Mar 2006 15:12:09 -0000, "Frinton" <fred_n***@hotmail.com>
>> wrote:
>>
>>>Hi,
>>>
>>>I am trying to do some calculations on large numbers (ie
>>>7,768,489,957,892,578,474,792,094 / 12,280) and no matter what I do it
>>>doesn't get it quite right. Its always somewhere between 10 and and 5000
>>>out
>>>:(
>>>
>>>I have a suspition is could be down to one of the number functions I am
>>>using along the way but im not sure.
>>>
>>>Any help or guidance would be greatly appriciated.
>>>
>>>Thanks in advance
>>>
>>>Fred
>>>
>> See tip 4533 » How do I perform accurate and/or complex math in a batch?
>> 11-Dec-01
>> in the 'Tips & Tricks' at http://www.jsifaq.com
>>
>> When I type the following at a CMD.EXE prompt:
>> for /f %i in ('domath //nologo "Round(7768489957892578474792094/12280)"')
>> do @echo %i
>>
>> I get 6.32613188753467E+20
>>
>>
>>
>>
>> Jerold Schulman
>> Windows Server MVP
>> JSI, Inc.
>> http://www.jsiinc.com
>> http://www.jsifaq.com
>
>
Author
13 Mar 2006 6:40 PM
Dave Anderson
Frinton wrote:
> I am trying to do some calculations on large numbers (ie
> 7,768,489,957,892,578,474,792,094 / 12,280) and no matter
> what I do it doesn't get it quite right. Its always
> somewhere between 10 and and 5000 out :(

Check out the multiple-precision libraries here:
http://www.ohdave.com/rsa/



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Author
13 Mar 2006 11:33 PM
Dr John Stockton
JRS:  In article <44158bca@212.67.96.135>, dated Mon, 13 Mar 2006
15:12:09 remote, seen in news:microsoft.public.scripting.vbscript,
Frinton <fred_n***@hotmail.com> posted :

>I am trying to do some calculations on large numbers (ie
>7,768,489,957,892,578,474,792,094 / 12,280) and no matter what I do it
>doesn't get it quite right. Its always somewhere between 10 and and 5000 out
>:(
>
>I have a suspition is could be down to one of the number functions I am
>using along the way but im not sure.

Others have explained size limits and accuracy.  But, at a DOS prompt :

        LONGCALC 7,768,489,957,892,578,474,792,094  12,280 div wrt

        LONGCALC: www.merlyn.demon.co.uk >= 2005-07-22
         compiled with Borland Delphi.
        +632,613,188,753,467,302,507

                                                (remainder was 6,134)

LONGCALC handles up to 65520 or 99999999 digits, base 2..16, integers,
programmed in RPN.  If you want the answers, you may use it; but it's
not VBS (and not quick).  Via sig line 3.  VASTCALC is a GUI version.

--
© John Stockton, Surrey, UK.  ?@merlyn.demon.co.uk   Turnpike v4.00   MIME. ©
Web  <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>.
Do not Mail News to me.    Before a reply, quote with ">" or "> " (SoRFC1036)
Author
14 Mar 2006 12:58 PM
Jerold Schulman
Is there any documentation on LONGCALC?
What does wrt mean?
I can figure out how to use  add, sub, mul, div/mod/srt, pow.
How do I do use the result of 1 calculation in another calculation?


On Mon, 13 Mar 2006 23:33:01 +0000, Dr John Stockton <j**@merlyn.demon.co.uk> wrote:

Show quote
>JRS:  In article <44158bca@212.67.96.135>, dated Mon, 13 Mar 2006
>15:12:09 remote, seen in news:microsoft.public.scripting.vbscript,
>Frinton <fred_n***@hotmail.com> posted :
>
>>I am trying to do some calculations on large numbers (ie
>>7,768,489,957,892,578,474,792,094 / 12,280) and no matter what I do it
>>doesn't get it quite right. Its always somewhere between 10 and and 5000 out
>>:(
>>
>>I have a suspition is could be down to one of the number functions I am
>>using along the way but im not sure.
>
>Others have explained size limits and accuracy.  But, at a DOS prompt :
>
>        LONGCALC 7,768,489,957,892,578,474,792,094  12,280 div wrt
>
>        LONGCALC: www.merlyn.demon.co.uk >= 2005-07-22
>         compiled with Borland Delphi.
>        +632,613,188,753,467,302,507
>
>                                                (remainder was 6,134)
>
>LONGCALC handles up to 65520 or 99999999 digits, base 2..16, integers,
>programmed in RPN.  If you want the answers, you may use it; but it's
>not VBS (and not quick).  Via sig line 3.  VASTCALC is a GUI version.
>

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com
Author
7 Apr 2006 2:17 AM
de Graff
If it is a one-time thing you can download the free version of Dolphin
SmallTalk which handles numbers of any size. For example you can evaluate

    1000 factorial.

in a fraction of a second. If you need to program something you can use Java
with the BigInteger class.

AddThis Social Bookmark Button