D
Dr John Stockton
JRS: In article <[email protected]>, dated Mon, 13
Mar 2006 17:50:35 remote, seen in
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
Mar 2006 17:50:35 remote, seen in
pt said: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