Array division 
Author Message
 Array division

I know that there are units and resources out there for doing math with
LARGE numbers, but I was wondering, suppose that I wanted to divide one
large number into another, and each number was loaded
into an array. For examples, I have to arrays, array1 = array[-50..50]
of integer, and array2 =
array[-50..50] of integer. And I want to divide 51343141 by 32431. I
know that those two numbers aren't very large, but this is just an
example. Then, I'd have array1[7]:=5, array1[6]:=1, array1[5]:=3,
array1[4]:=4, array1[3]:=3, array1[2]:=1, array1[1]:=4, and
array1[0]:=1. You get the idea. Each digit is put into the element which
corresponds do it's decimal position. In this case, array1[0] = the 1's
place becase 10^0=1, array1[1] is the 10's place because 10^1=10, etc.
Also, there would be an answer array
array3 = array[-50..50] of integer for the results.

The number 32431 is entered into array2 in the same way. What I want to
know is, is there a fast good algorithm for dividing such two numbers?
For dividing array2 into array1? Isn't there a book called
"Numerical Recipies" Is the algorithm there?

If not, is there a unit out there on the internet which can deal with
LARGE numbers this way, and which has good documentation so that I'll
know right away how to do this? TIA for any help here.

--
Patrick D. Rockwell





Wed, 18 Jun 1902 08:00:00 GMT  
 Array division

Quote:

> I know that there are units and resources out there for doing math with
> LARGE numbers, but I was wondering, suppose that I wanted to divide one
> large number into another, and each number was loaded
> into an array. For examples, I have to arrays, array1 = array[-50..50]
> of integer, and array2 =
> array[-50..50] of integer. And I want to divide 51343141 by 32431. I
> know that those two numbers aren't very large, but this is just an
> example. Then, I'd have array1[7]:=5, array1[6]:=1, array1[5]:=3,
> array1[4]:=4, array1[3]:=3, array1[2]:=1, array1[1]:=4, and
> array1[0]:=1. You get the idea.

Most units use binary numbers, not BCD encoded ones, and carry MPI
(multiple(?) precision integers) in their name.

The nearest place for an example is the Borland Pascal RTL, the
longint/longint division, or if you don't own the sources, check a free
compiler and its 64-bit/64-bit integer type division.

Numerically good solutions can probably be obtained via the standard
source for mathematical problems:
http://www-rab.larc.nasa.gov/nmp/fNMPhome.htm

Somewhere there a link to GMP (a much used GNU C solution) also exists.

And of course SWAG (www.gdsoft.org) also always has some sources you
could use.

Quote:
> Each digit is put into the element which
> corresponds do it's decimal position. In this case, array1[0] = the 1's
> place becase 10^0=1, array1[1] is the 10's place because 10^1=10, etc.
> Also, there would be an answer array
> array3 = array[-50..50] of integer for the results.

> The number 32431 is entered into array2 in the same way. What I want to
> know is, is there a fast good algorithm for dividing such two numbers?
> For dividing array2 into array1? Isn't there a book called
> "Numerical Recipies" Is the algorithm there?

You could solve this the same way as you do by hand, though it probably
won't be the best way.

All it takes is being able to multiply such numbers by a small number
(maximally base-1), and comparing/subtracting of two such numbers.

--




Wed, 18 Jun 1902 08:00:00 GMT  
 Array division

Quote:

> > I know that there are units and resources out there for doing math with
> > LARGE numbers, but I was wondering, suppose that I wanted to divide one
> > large number into another, and each number was loaded
> > into an array. For examples, I have to arrays, array1 = array[-50..50]
> > of integer, and array2 =
> > array[-50..50] of integer. And I want to divide 51343141 by 32431. I
> > know that those two numbers aren't very large, but this is just an
> > example. Then, I'd have array1[7]:=5, array1[6]:=1, array1[5]:=3,
> > array1[4]:=4, array1[3]:=3, array1[2]:=1, array1[1]:=4, and
> > array1[0]:=1. You get the idea.

> Most units use binary numbers, not BCD encoded ones, and carry MPI
> (multiple(?) precision integers) in their name.

> The nearest place for an example is the Borland Pascal RTL, the
> longint/longint division, or if you don't own the sources, check a free
> compiler and its 64-bit/64-bit integer type division.

> Numerically good solutions can probably be obtained via the standard
> source for mathematical problems:
> http://www-rab.larc.nasa.gov/nmp/fNMPhome.htm

> Somewhere there a link to GMP (a much used GNU C solution) also exists.

> And of course SWAG (www.gdsoft.org) also always has some sources you
> could use.

> > Each digit is put into the element which
> > corresponds do it's decimal position. In this case, array1[0] = the 1's
> > place becase 10^0=1, array1[1] is the 10's place because 10^1=10, etc.
> > Also, there would be an answer array
> > array3 = array[-50..50] of integer for the results.

> > The number 32431 is entered into array2 in the same way. What I want to
> > know is, is there a fast good algorithm for dividing such two numbers?
> > For dividing array2 into array1? Isn't there a book called
> > "Numerical Recipies" Is the algorithm there?

> You could solve this the same way as you do by hand, though it probably
> won't be the best way.

That's just it. When humans do it on paper, they can make a visual inspection
of ALL of the digits
in each number. I find that implementing this on a computer in these arrays
isn't so cut & dry.

For example, lets say that I want to divide 2222222222222 by 111117.   The
answer is 199989400.5618.

If you start by taking the first digit of each number, in this case, 2 and 1
respectively, you might believe
that the first digit of the answer is two, but the last digit of the dividend
(7) is higher than any number
in the diviser, so the first digit in the quotient is 1.

This can be done, I'd just like to have a FAST way of doing it.

Thanks for the info that you've given me, and in advance for all of the
answers that I may receive in the
future. Would this sort of thing be in the book called 'Numerical recipies'?
Does anyone have that book?
Is that the right title, or is it 'Numerical recipies for Turbo Pascal'?

Quote:
> All it takes is being able to multiply such numbers by a small number
> (maximally base-1), and comparing/subtracting of two such numbers.

What's base-1?

--
Patrick D. Rockwell





Wed, 18 Jun 1902 08:00:00 GMT  
 Array division


Quote:

>I know that there are units and resources out there for doing math with
>LARGE numbers, but I was wondering, suppose that I wanted to divide one
>large number into another, and each number was loaded
>into an array. For examples, I have to arrays, array1 = array[-50..50]
>of integer, and array2 =
>array[-50..50] of integer. And I want to divide 51343141 by 32431. I
>know that those two numbers aren't very large, but this is just an
>example. Then, I'd have array1[7]:=5, array1[6]:=1, array1[5]:=3,
>array1[4]:=4, array1[3]:=3, array1[2]:=1, array1[1]:=4, and
>array1[0]:=1. You get the idea. Each digit is put into the element which
>corresponds do it's decimal position. In this case, array1[0] = the 1's
>place becase 10^0=1, array1[1] is the 10's place because 10^1=10, etc.
>Also, there would be an answer array
>array3 = array[-50..50] of integer for the results.

>The number 32431 is entered into array2 in the same way. What I want to
>know is, is there a fast good algorithm for dividing such two numbers?
>For dividing array2 into array1? Isn't there a book called
>"Numerical Recipies" Is the algorithm there?

>If not, is there a unit out there on the internet which can deal with
>LARGE numbers this way,

Yes; longcalc.pas (sig line 3), needs version.pas, compiled without
"program" defined.  But for integers only.  Expects BP7 (or D3) but
could be adapted for TP6 I think.  Fdiv calls Divide calls Divd.

Quote:
> and which has good documentation so that I'll
>know right away how to do this? TIA for any help here.

The only documentation is in the file.

The method is as taught in school, when I was a lad.

I don't actually know a faster way, though there probably is one.  One
might investigate Newton-Raphson, for example; or taking the reciprocal
of y and then multiplying by x.

--

 Web <URL: http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
 PAS, EXE in <URL: http://www.merlyn.demon.co.uk/programs/> - see 00index.txt.
 Do not Mail News to me.    Before a reply, quote with ">" or "> " (SoRFC1036)



Wed, 18 Jun 1902 08:00:00 GMT  
 Array division
On Sat, 02 Dec 2000 14:00:16 -0800, "Patrick D. Rockwell"

<snipped>

Quote:
>Would this sort of thing be in the book called 'Numerical recipies'?
>Does anyone have that book?
>Is that the right title, or is it 'Numerical recipies for Turbo Pascal'?

My copy of the book is:

TITLE....: Numerical Recipes in Pascal: The Art of Scientific
           Computing
AUTHOR...: Press, William H. & etal
PUBLISHER: Cambridge University Press
YEAR.....: 1989     PAGES:  759    ISBN: 0-621-37516-9    List: 44.50
CATEGORY.: Computer, Lang, Pascal

<snipped>

Steve
----
due to SPAM robots, I no longer post my e-mail address



Sun, 01 Jun 2003 23:11:11 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Array of Array

2. move INTERBASE ARRAY to DELPHI ARRAY ?

3. lgarray0.zip TP unit for huge arrays and arrays of sorted strings

4. floating point arrays and C arrays - HELP ME

5. Help! array of type array

6. Euclidian division of two polynomials

7. Division by zero during batch I/O

8. RTE 200: division by zero

9. Division by Zero!

10. RTE 200: Division by zero

11. Division by Zero

12. Copy II PC and Division by zero

 

 
Powered by phpBB® Forum Software