Author 
Message 
Patrick D. Rockwel #1 / 5

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 


Marco van de Voor #2 / 5

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 64bit/64bit integer type division. Numerically good solutions can probably be obtained via the standard source for mathematical problems: http://wwwrab.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 base1), and comparing/subtracting of two such numbers. 

Wed, 18 Jun 1902 08:00:00 GMT 


Patrick D. Rockwel #3 / 5

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 64bit/64bit integer type division. > Numerically good solutions can probably be obtained via the standard > source for mathematical problems: > http://wwwrab.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 base1), and comparing/subtracting of two such numbers.
What's base1?  Patrick D. Rockwell

Wed, 18 Jun 1902 08:00:00 GMT 


Dr John Stockto #4 / 5

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 NewtonRaphson, 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 


smread_bog.. #5 / 5

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: 0621375169 List: 44.50 CATEGORY.: Computer, Lang, Pascal <snipped> Steve  due to SPAM robots, I no longer post my email address

Sun, 01 Jun 2003 23:11:11 GMT 


