Home » Archimedes archive » Acorn User » AU 1995-11.adf » !Regulars » Regulars/StarInfo/Radford/ReadMe

Regulars/StarInfo/Radford/ReadMe

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Acorn User » AU 1995-11.adf » !Regulars
Filename: Regulars/StarInfo/Radford/ReadMe
Read OK:
File size: 0F6B bytes
Load address: 0000
Exec address: 0000
File contents
Detailed on this disk are several Assembler Libraries that will add, multiply and divide any number to an unlimited degree of accuracy dependent only upon memory constraints.  Currently these limits are set to numbers of 400 digits in length, but these may be altered to suit numbers of any length.

The three files "ASS_ADD", "ASS_DIV", "ASS_MUL" are demonstration files of the routines and will add, divide and multiply any integers up to 400 digits in length.  To run these simply double click on the file and type in the numbers you wish the routine to operate on.

The three libraries are unified into one general library called "Calc_lib", thus all of these routines can be used from any basic program without any understanding of how these routines work.  This library is used as follows:-

i.) First you must make a call to assemble the code this is done with the following command

PROCassemble_calculator

ii.) Next you must specify the operand to be used by the respective routine, this is done as follows:-


operand1$="          first number          "
operand2$="         second number          "
operand1?0=0
operand2?0=0

FOR A=1 TO LEN(operand1$)
operand1?(A)=VAL(MID$(operand1$,A,1))
NEXT
operand1?(A)=10

FOR A=1 TO LEN(operand2$)
operand2?(A)=VAL(MID$(operand2$,A,1))
NEXT
operand2?(A)=10

Each routine takes its input as a series of bytes contained in operand1 and operand2, the first byte of which must be a 0.  values of 1-9 correspeond to the actual digits one to nine, and a value of ten corresponds to the terminating byte in each of the operands, e.g. to specify operand 1 as 21 you could use the following :-

operand1?0=0     \ leading 0
operand1?1=2
operand1?2=1
operand1?3=10    \ terminating byte

iii.)

finally you must call the routine:-

USE EITHER  : CALL begin_addition
            : CALL begin_division
            : CALL begin_multiplication

the result is returned in the variable 'result' and is terminated by a value of 10, it could be accessed as follows:-

A=0
REPEAT
PRINT STR$((result?A));
A+=1
UNTIL result?(A+1)=10


IF both operands 1 and 2 and the result were passed as simple strings then calculations would be restricted to a maximum accuracy of 256 digits, since this is the maximum length for a string under RISC OS, this is why the above convention for passing the operands is used.


Floating point addition, division, and multiplication can be achieved by multiplying up the first operand by a very large number, say 10^100, the result is in effect (10^100 * the answer) and will include 10^100 digits past the decimal point. e.g. to divide 1 by 3 could be done as follows :

make operand 1  = 10^100
make operand 2  = 3
call the division routine
The result will be given as 10^100 * 1/3.



A more complex example of this is given by the program "ASS_ECALC".  This program calculates the number e (normally detailed as 2.718281828459) to a specified degree of accuracy.  It uses the basis that e can be calculated from the expansion :-

      e =  { 1/0! + 1/1! + 1/2! + 1/3! + 1/4! + ..... 1/n! }

This program can calculate the factorial of very large numbers - a separate routine that illustrates this is called "fctrial" on the disc.

the final result is given as e * 10^accuracy, where accuracy is the initial accuracy specified.

The accuracy of the result, and the number of terms used to provide the approximation can be altered by changing the following variables at the beginning of the program:-

it%= the number of iterations (initially 100)
acc2% = the accuracy of the result (initially 100)


 *********************************************************************************************
 ** the number 'e' listed to 1990 decimal places in contained in the file 'e' - the program **
 ** took just under 24 hours to calculate all 2000 terms to nearly 2000 decimal places      **
 *********************************************************************************************

00000000  44 65 74 61 69 6c 65 64  20 6f 6e 20 74 68 69 73  |Detailed on this|
00000010  20 64 69 73 6b 20 61 72  65 20 73 65 76 65 72 61  | disk are severa|
00000020  6c 20 41 73 73 65 6d 62  6c 65 72 20 4c 69 62 72  |l Assembler Libr|
00000030  61 72 69 65 73 20 74 68  61 74 20 77 69 6c 6c 20  |aries that will |
00000040  61 64 64 2c 20 6d 75 6c  74 69 70 6c 79 20 61 6e  |add, multiply an|
00000050  64 20 64 69 76 69 64 65  20 61 6e 79 20 6e 75 6d  |d divide any num|
00000060  62 65 72 20 74 6f 20 61  6e 20 75 6e 6c 69 6d 69  |ber to an unlimi|
00000070  74 65 64 20 64 65 67 72  65 65 20 6f 66 20 61 63  |ted degree of ac|
00000080  63 75 72 61 63 79 20 64  65 70 65 6e 64 65 6e 74  |curacy dependent|
00000090  20 6f 6e 6c 79 20 75 70  6f 6e 20 6d 65 6d 6f 72  | only upon memor|
000000a0  79 20 63 6f 6e 73 74 72  61 69 6e 74 73 2e 20 20  |y constraints.  |
000000b0  43 75 72 72 65 6e 74 6c  79 20 74 68 65 73 65 20  |Currently these |
000000c0  6c 69 6d 69 74 73 20 61  72 65 20 73 65 74 20 74  |limits are set t|
000000d0  6f 20 6e 75 6d 62 65 72  73 20 6f 66 20 34 30 30  |o numbers of 400|
000000e0  20 64 69 67 69 74 73 20  69 6e 20 6c 65 6e 67 74  | digits in lengt|
000000f0  68 2c 20 62 75 74 20 74  68 65 73 65 20 6d 61 79  |h, but these may|
00000100  20 62 65 20 61 6c 74 65  72 65 64 20 74 6f 20 73  | be altered to s|
00000110  75 69 74 20 6e 75 6d 62  65 72 73 20 6f 66 20 61  |uit numbers of a|
00000120  6e 79 20 6c 65 6e 67 74  68 2e 0a 0a 54 68 65 20  |ny length...The |
00000130  74 68 72 65 65 20 66 69  6c 65 73 20 22 41 53 53  |three files "ASS|
00000140  5f 41 44 44 22 2c 20 22  41 53 53 5f 44 49 56 22  |_ADD", "ASS_DIV"|
00000150  2c 20 22 41 53 53 5f 4d  55 4c 22 20 61 72 65 20  |, "ASS_MUL" are |
00000160  64 65 6d 6f 6e 73 74 72  61 74 69 6f 6e 20 66 69  |demonstration fi|
00000170  6c 65 73 20 6f 66 20 74  68 65 20 72 6f 75 74 69  |les of the routi|
00000180  6e 65 73 20 61 6e 64 20  77 69 6c 6c 20 61 64 64  |nes and will add|
00000190  2c 20 64 69 76 69 64 65  20 61 6e 64 20 6d 75 6c  |, divide and mul|
000001a0  74 69 70 6c 79 20 61 6e  79 20 69 6e 74 65 67 65  |tiply any intege|
000001b0  72 73 20 75 70 20 74 6f  20 34 30 30 20 64 69 67  |rs up to 400 dig|
000001c0  69 74 73 20 69 6e 20 6c  65 6e 67 74 68 2e 20 20  |its in length.  |
000001d0  54 6f 20 72 75 6e 20 74  68 65 73 65 20 73 69 6d  |To run these sim|
000001e0  70 6c 79 20 64 6f 75 62  6c 65 20 63 6c 69 63 6b  |ply double click|
000001f0  20 6f 6e 20 74 68 65 20  66 69 6c 65 20 61 6e 64  | on the file and|
00000200  20 74 79 70 65 20 69 6e  20 74 68 65 20 6e 75 6d  | type in the num|
00000210  62 65 72 73 20 79 6f 75  20 77 69 73 68 20 74 68  |bers you wish th|
00000220  65 20 72 6f 75 74 69 6e  65 20 74 6f 20 6f 70 65  |e routine to ope|
00000230  72 61 74 65 20 6f 6e 2e  0a 0a 54 68 65 20 74 68  |rate on...The th|
00000240  72 65 65 20 6c 69 62 72  61 72 69 65 73 20 61 72  |ree libraries ar|
00000250  65 20 75 6e 69 66 69 65  64 20 69 6e 74 6f 20 6f  |e unified into o|
00000260  6e 65 20 67 65 6e 65 72  61 6c 20 6c 69 62 72 61  |ne general libra|
00000270  72 79 20 63 61 6c 6c 65  64 20 22 43 61 6c 63 5f  |ry called "Calc_|
00000280  6c 69 62 22 2c 20 74 68  75 73 20 61 6c 6c 20 6f  |lib", thus all o|
00000290  66 20 74 68 65 73 65 20  72 6f 75 74 69 6e 65 73  |f these routines|
000002a0  20 63 61 6e 20 62 65 20  75 73 65 64 20 66 72 6f  | can be used fro|
000002b0  6d 20 61 6e 79 20 62 61  73 69 63 20 70 72 6f 67  |m any basic prog|
000002c0  72 61 6d 20 77 69 74 68  6f 75 74 20 61 6e 79 20  |ram without any |
000002d0  75 6e 64 65 72 73 74 61  6e 64 69 6e 67 20 6f 66  |understanding of|
000002e0  20 68 6f 77 20 74 68 65  73 65 20 72 6f 75 74 69  | how these routi|
000002f0  6e 65 73 20 77 6f 72 6b  2e 20 20 54 68 69 73 20  |nes work.  This |
00000300  6c 69 62 72 61 72 79 20  69 73 20 75 73 65 64 20  |library is used |
00000310  61 73 20 66 6f 6c 6c 6f  77 73 3a 2d 0a 0a 69 2e  |as follows:-..i.|
00000320  29 20 46 69 72 73 74 20  79 6f 75 20 6d 75 73 74  |) First you must|
00000330  20 6d 61 6b 65 20 61 20  63 61 6c 6c 20 74 6f 20  | make a call to |
00000340  61 73 73 65 6d 62 6c 65  20 74 68 65 20 63 6f 64  |assemble the cod|
00000350  65 20 74 68 69 73 20 69  73 20 64 6f 6e 65 20 77  |e this is done w|
00000360  69 74 68 20 74 68 65 20  66 6f 6c 6c 6f 77 69 6e  |ith the followin|
00000370  67 20 63 6f 6d 6d 61 6e  64 0a 0a 50 52 4f 43 61  |g command..PROCa|
00000380  73 73 65 6d 62 6c 65 5f  63 61 6c 63 75 6c 61 74  |ssemble_calculat|
00000390  6f 72 0a 0a 69 69 2e 29  20 4e 65 78 74 20 79 6f  |or..ii.) Next yo|
000003a0  75 20 6d 75 73 74 20 73  70 65 63 69 66 79 20 74  |u must specify t|
000003b0  68 65 20 6f 70 65 72 61  6e 64 20 74 6f 20 62 65  |he operand to be|
000003c0  20 75 73 65 64 20 62 79  20 74 68 65 20 72 65 73  | used by the res|
000003d0  70 65 63 74 69 76 65 20  72 6f 75 74 69 6e 65 2c  |pective routine,|
000003e0  20 74 68 69 73 20 69 73  20 64 6f 6e 65 20 61 73  | this is done as|
000003f0  20 66 6f 6c 6c 6f 77 73  3a 2d 0a 0a 0a 6f 70 65  | follows:-...ope|
00000400  72 61 6e 64 31 24 3d 22  20 20 20 20 20 20 20 20  |rand1$="        |
00000410  20 20 66 69 72 73 74 20  6e 75 6d 62 65 72 20 20  |  first number  |
00000420  20 20 20 20 20 20 20 20  22 0a 6f 70 65 72 61 6e  |        ".operan|
00000430  64 32 24 3d 22 20 20 20  20 20 20 20 20 20 73 65  |d2$="         se|
00000440  63 6f 6e 64 20 6e 75 6d  62 65 72 20 20 20 20 20  |cond number     |
00000450  20 20 20 20 20 22 0a 6f  70 65 72 61 6e 64 31 3f  |     ".operand1?|
00000460  30 3d 30 0a 6f 70 65 72  61 6e 64 32 3f 30 3d 30  |0=0.operand2?0=0|
00000470  0a 0a 46 4f 52 20 41 3d  31 20 54 4f 20 4c 45 4e  |..FOR A=1 TO LEN|
00000480  28 6f 70 65 72 61 6e 64  31 24 29 0a 6f 70 65 72  |(operand1$).oper|
00000490  61 6e 64 31 3f 28 41 29  3d 56 41 4c 28 4d 49 44  |and1?(A)=VAL(MID|
000004a0  24 28 6f 70 65 72 61 6e  64 31 24 2c 41 2c 31 29  |$(operand1$,A,1)|
000004b0  29 0a 4e 45 58 54 0a 6f  70 65 72 61 6e 64 31 3f  |).NEXT.operand1?|
000004c0  28 41 29 3d 31 30 0a 0a  46 4f 52 20 41 3d 31 20  |(A)=10..FOR A=1 |
000004d0  54 4f 20 4c 45 4e 28 6f  70 65 72 61 6e 64 32 24  |TO LEN(operand2$|
000004e0  29 0a 6f 70 65 72 61 6e  64 32 3f 28 41 29 3d 56  |).operand2?(A)=V|
000004f0  41 4c 28 4d 49 44 24 28  6f 70 65 72 61 6e 64 32  |AL(MID$(operand2|
00000500  24 2c 41 2c 31 29 29 0a  4e 45 58 54 0a 6f 70 65  |$,A,1)).NEXT.ope|
00000510  72 61 6e 64 32 3f 28 41  29 3d 31 30 0a 0a 45 61  |rand2?(A)=10..Ea|
00000520  63 68 20 72 6f 75 74 69  6e 65 20 74 61 6b 65 73  |ch routine takes|
00000530  20 69 74 73 20 69 6e 70  75 74 20 61 73 20 61 20  | its input as a |
00000540  73 65 72 69 65 73 20 6f  66 20 62 79 74 65 73 20  |series of bytes |
00000550  63 6f 6e 74 61 69 6e 65  64 20 69 6e 20 6f 70 65  |contained in ope|
00000560  72 61 6e 64 31 20 61 6e  64 20 6f 70 65 72 61 6e  |rand1 and operan|
00000570  64 32 2c 20 74 68 65 20  66 69 72 73 74 20 62 79  |d2, the first by|
00000580  74 65 20 6f 66 20 77 68  69 63 68 20 6d 75 73 74  |te of which must|
00000590  20 62 65 20 61 20 30 2e  20 20 76 61 6c 75 65 73  | be a 0.  values|
000005a0  20 6f 66 20 31 2d 39 20  63 6f 72 72 65 73 70 65  | of 1-9 correspe|
000005b0  6f 6e 64 20 74 6f 20 74  68 65 20 61 63 74 75 61  |ond to the actua|
000005c0  6c 20 64 69 67 69 74 73  20 6f 6e 65 20 74 6f 20  |l digits one to |
000005d0  6e 69 6e 65 2c 20 61 6e  64 20 61 20 76 61 6c 75  |nine, and a valu|
000005e0  65 20 6f 66 20 74 65 6e  20 63 6f 72 72 65 73 70  |e of ten corresp|
000005f0  6f 6e 64 73 20 74 6f 20  74 68 65 20 74 65 72 6d  |onds to the term|
00000600  69 6e 61 74 69 6e 67 20  62 79 74 65 20 69 6e 20  |inating byte in |
00000610  65 61 63 68 20 6f 66 20  74 68 65 20 6f 70 65 72  |each of the oper|
00000620  61 6e 64 73 2c 20 65 2e  67 2e 20 74 6f 20 73 70  |ands, e.g. to sp|
00000630  65 63 69 66 79 20 6f 70  65 72 61 6e 64 20 31 20  |ecify operand 1 |
00000640  61 73 20 32 31 20 79 6f  75 20 63 6f 75 6c 64 20  |as 21 you could |
00000650  75 73 65 20 74 68 65 20  66 6f 6c 6c 6f 77 69 6e  |use the followin|
00000660  67 20 3a 2d 0a 0a 6f 70  65 72 61 6e 64 31 3f 30  |g :-..operand1?0|
00000670  3d 30 20 20 20 20 20 5c  20 6c 65 61 64 69 6e 67  |=0     \ leading|
00000680  20 30 0a 6f 70 65 72 61  6e 64 31 3f 31 3d 32 0a  | 0.operand1?1=2.|
00000690  6f 70 65 72 61 6e 64 31  3f 32 3d 31 0a 6f 70 65  |operand1?2=1.ope|
000006a0  72 61 6e 64 31 3f 33 3d  31 30 20 20 20 20 5c 20  |rand1?3=10    \ |
000006b0  74 65 72 6d 69 6e 61 74  69 6e 67 20 62 79 74 65  |terminating byte|
000006c0  0a 0a 69 69 69 2e 29 0a  0a 66 69 6e 61 6c 6c 79  |..iii.)..finally|
000006d0  20 79 6f 75 20 6d 75 73  74 20 63 61 6c 6c 20 74  | you must call t|
000006e0  68 65 20 72 6f 75 74 69  6e 65 3a 2d 0a 0a 55 53  |he routine:-..US|
000006f0  45 20 45 49 54 48 45 52  20 20 3a 20 43 41 4c 4c  |E EITHER  : CALL|
00000700  20 62 65 67 69 6e 5f 61  64 64 69 74 69 6f 6e 0a  | begin_addition.|
00000710  20 20 20 20 20 20 20 20  20 20 20 20 3a 20 43 41  |            : CA|
00000720  4c 4c 20 62 65 67 69 6e  5f 64 69 76 69 73 69 6f  |LL begin_divisio|
00000730  6e 0a 20 20 20 20 20 20  20 20 20 20 20 20 3a 20  |n.            : |
00000740  43 41 4c 4c 20 62 65 67  69 6e 5f 6d 75 6c 74 69  |CALL begin_multi|
00000750  70 6c 69 63 61 74 69 6f  6e 0a 0a 74 68 65 20 72  |plication..the r|
00000760  65 73 75 6c 74 20 69 73  20 72 65 74 75 72 6e 65  |esult is returne|
00000770  64 20 69 6e 20 74 68 65  20 76 61 72 69 61 62 6c  |d in the variabl|
00000780  65 20 27 72 65 73 75 6c  74 27 20 61 6e 64 20 69  |e 'result' and i|
00000790  73 20 74 65 72 6d 69 6e  61 74 65 64 20 62 79 20  |s terminated by |
000007a0  61 20 76 61 6c 75 65 20  6f 66 20 31 30 2c 20 69  |a value of 10, i|
000007b0  74 20 63 6f 75 6c 64 20  62 65 20 61 63 63 65 73  |t could be acces|
000007c0  73 65 64 20 61 73 20 66  6f 6c 6c 6f 77 73 3a 2d  |sed as follows:-|
000007d0  0a 0a 41 3d 30 0a 52 45  50 45 41 54 0a 50 52 49  |..A=0.REPEAT.PRI|
000007e0  4e 54 20 53 54 52 24 28  28 72 65 73 75 6c 74 3f  |NT STR$((result?|
000007f0  41 29 29 3b 0a 41 2b 3d  31 0a 55 4e 54 49 4c 20  |A));.A+=1.UNTIL |
00000800  72 65 73 75 6c 74 3f 28  41 2b 31 29 3d 31 30 0a  |result?(A+1)=10.|
00000810  0a 0a 49 46 20 62 6f 74  68 20 6f 70 65 72 61 6e  |..IF both operan|
00000820  64 73 20 31 20 61 6e 64  20 32 20 61 6e 64 20 74  |ds 1 and 2 and t|
00000830  68 65 20 72 65 73 75 6c  74 20 77 65 72 65 20 70  |he result were p|
00000840  61 73 73 65 64 20 61 73  20 73 69 6d 70 6c 65 20  |assed as simple |
00000850  73 74 72 69 6e 67 73 20  74 68 65 6e 20 63 61 6c  |strings then cal|
00000860  63 75 6c 61 74 69 6f 6e  73 20 77 6f 75 6c 64 20  |culations would |
00000870  62 65 20 72 65 73 74 72  69 63 74 65 64 20 74 6f  |be restricted to|
00000880  20 61 20 6d 61 78 69 6d  75 6d 20 61 63 63 75 72  | a maximum accur|
00000890  61 63 79 20 6f 66 20 32  35 36 20 64 69 67 69 74  |acy of 256 digit|
000008a0  73 2c 20 73 69 6e 63 65  20 74 68 69 73 20 69 73  |s, since this is|
000008b0  20 74 68 65 20 6d 61 78  69 6d 75 6d 20 6c 65 6e  | the maximum len|
000008c0  67 74 68 20 66 6f 72 20  61 20 73 74 72 69 6e 67  |gth for a string|
000008d0  20 75 6e 64 65 72 20 52  49 53 43 20 4f 53 2c 20  | under RISC OS, |
000008e0  74 68 69 73 20 69 73 20  77 68 79 20 74 68 65 20  |this is why the |
000008f0  61 62 6f 76 65 20 63 6f  6e 76 65 6e 74 69 6f 6e  |above convention|
00000900  20 66 6f 72 20 70 61 73  73 69 6e 67 20 74 68 65  | for passing the|
00000910  20 6f 70 65 72 61 6e 64  73 20 69 73 20 75 73 65  | operands is use|
00000920  64 2e 0a 0a 0a 46 6c 6f  61 74 69 6e 67 20 70 6f  |d....Floating po|
00000930  69 6e 74 20 61 64 64 69  74 69 6f 6e 2c 20 64 69  |int addition, di|
00000940  76 69 73 69 6f 6e 2c 20  61 6e 64 20 6d 75 6c 74  |vision, and mult|
00000950  69 70 6c 69 63 61 74 69  6f 6e 20 63 61 6e 20 62  |iplication can b|
00000960  65 20 61 63 68 69 65 76  65 64 20 62 79 20 6d 75  |e achieved by mu|
00000970  6c 74 69 70 6c 79 69 6e  67 20 75 70 20 74 68 65  |ltiplying up the|
00000980  20 66 69 72 73 74 20 6f  70 65 72 61 6e 64 20 62  | first operand b|
00000990  79 20 61 20 76 65 72 79  20 6c 61 72 67 65 20 6e  |y a very large n|
000009a0  75 6d 62 65 72 2c 20 73  61 79 20 31 30 5e 31 30  |umber, say 10^10|
000009b0  30 2c 20 74 68 65 20 72  65 73 75 6c 74 20 69 73  |0, the result is|
000009c0  20 69 6e 20 65 66 66 65  63 74 20 28 31 30 5e 31  | in effect (10^1|
000009d0  30 30 20 2a 20 74 68 65  20 61 6e 73 77 65 72 29  |00 * the answer)|
000009e0  20 61 6e 64 20 77 69 6c  6c 20 69 6e 63 6c 75 64  | and will includ|
000009f0  65 20 31 30 5e 31 30 30  20 64 69 67 69 74 73 20  |e 10^100 digits |
00000a00  70 61 73 74 20 74 68 65  20 64 65 63 69 6d 61 6c  |past the decimal|
00000a10  20 70 6f 69 6e 74 2e 20  65 2e 67 2e 20 74 6f 20  | point. e.g. to |
00000a20  64 69 76 69 64 65 20 31  20 62 79 20 33 20 63 6f  |divide 1 by 3 co|
00000a30  75 6c 64 20 62 65 20 64  6f 6e 65 20 61 73 20 66  |uld be done as f|
00000a40  6f 6c 6c 6f 77 73 20 3a  0a 0a 6d 61 6b 65 20 6f  |ollows :..make o|
00000a50  70 65 72 61 6e 64 20 31  20 20 3d 20 31 30 5e 31  |perand 1  = 10^1|
00000a60  30 30 0a 6d 61 6b 65 20  6f 70 65 72 61 6e 64 20  |00.make operand |
00000a70  32 20 20 3d 20 33 0a 63  61 6c 6c 20 74 68 65 20  |2  = 3.call the |
00000a80  64 69 76 69 73 69 6f 6e  20 72 6f 75 74 69 6e 65  |division routine|
00000a90  0a 54 68 65 20 72 65 73  75 6c 74 20 77 69 6c 6c  |.The result will|
00000aa0  20 62 65 20 67 69 76 65  6e 20 61 73 20 31 30 5e  | be given as 10^|
00000ab0  31 30 30 20 2a 20 31 2f  33 2e 0a 0a 0a 0a 41 20  |100 * 1/3.....A |
00000ac0  6d 6f 72 65 20 63 6f 6d  70 6c 65 78 20 65 78 61  |more complex exa|
00000ad0  6d 70 6c 65 20 6f 66 20  74 68 69 73 20 69 73 20  |mple of this is |
00000ae0  67 69 76 65 6e 20 62 79  20 74 68 65 20 70 72 6f  |given by the pro|
00000af0  67 72 61 6d 20 22 41 53  53 5f 45 43 41 4c 43 22  |gram "ASS_ECALC"|
00000b00  2e 20 20 54 68 69 73 20  70 72 6f 67 72 61 6d 20  |.  This program |
00000b10  63 61 6c 63 75 6c 61 74  65 73 20 74 68 65 20 6e  |calculates the n|
00000b20  75 6d 62 65 72 20 65 20  28 6e 6f 72 6d 61 6c 6c  |umber e (normall|
00000b30  79 20 64 65 74 61 69 6c  65 64 20 61 73 20 32 2e  |y detailed as 2.|
00000b40  37 31 38 32 38 31 38 32  38 34 35 39 29 20 74 6f  |718281828459) to|
00000b50  20 61 20 73 70 65 63 69  66 69 65 64 20 64 65 67  | a specified deg|
00000b60  72 65 65 20 6f 66 20 61  63 63 75 72 61 63 79 2e  |ree of accuracy.|
00000b70  20 20 49 74 20 75 73 65  73 20 74 68 65 20 62 61  |  It uses the ba|
00000b80  73 69 73 20 74 68 61 74  20 65 20 63 61 6e 20 62  |sis that e can b|
00000b90  65 20 63 61 6c 63 75 6c  61 74 65 64 20 66 72 6f  |e calculated fro|
00000ba0  6d 20 74 68 65 20 65 78  70 61 6e 73 69 6f 6e 20  |m the expansion |
00000bb0  3a 2d 0a 0a 20 20 20 20  20 20 65 20 3d 20 20 7b  |:-..      e =  {|
00000bc0  20 31 2f 30 21 20 2b 20  31 2f 31 21 20 2b 20 31  | 1/0! + 1/1! + 1|
00000bd0  2f 32 21 20 2b 20 31 2f  33 21 20 2b 20 31 2f 34  |/2! + 1/3! + 1/4|
00000be0  21 20 2b 20 2e 2e 2e 2e  2e 20 31 2f 6e 21 20 7d  |! + ..... 1/n! }|
00000bf0  0a 0a 54 68 69 73 20 70  72 6f 67 72 61 6d 20 63  |..This program c|
00000c00  61 6e 20 63 61 6c 63 75  6c 61 74 65 20 74 68 65  |an calculate the|
00000c10  20 66 61 63 74 6f 72 69  61 6c 20 6f 66 20 76 65  | factorial of ve|
00000c20  72 79 20 6c 61 72 67 65  20 6e 75 6d 62 65 72 73  |ry large numbers|
00000c30  20 2d 20 61 20 73 65 70  61 72 61 74 65 20 72 6f  | - a separate ro|
00000c40  75 74 69 6e 65 20 74 68  61 74 20 69 6c 6c 75 73  |utine that illus|
00000c50  74 72 61 74 65 73 20 74  68 69 73 20 69 73 20 63  |trates this is c|
00000c60  61 6c 6c 65 64 20 22 66  63 74 72 69 61 6c 22 20  |alled "fctrial" |
00000c70  6f 6e 20 74 68 65 20 64  69 73 63 2e 0a 0a 74 68  |on the disc...th|
00000c80  65 20 66 69 6e 61 6c 20  72 65 73 75 6c 74 20 69  |e final result i|
00000c90  73 20 67 69 76 65 6e 20  61 73 20 65 20 2a 20 31  |s given as e * 1|
00000ca0  30 5e 61 63 63 75 72 61  63 79 2c 20 77 68 65 72  |0^accuracy, wher|
00000cb0  65 20 61 63 63 75 72 61  63 79 20 69 73 20 74 68  |e accuracy is th|
00000cc0  65 20 69 6e 69 74 69 61  6c 20 61 63 63 75 72 61  |e initial accura|
00000cd0  63 79 20 73 70 65 63 69  66 69 65 64 2e 0a 0a 54  |cy specified...T|
00000ce0  68 65 20 61 63 63 75 72  61 63 79 20 6f 66 20 74  |he accuracy of t|
00000cf0  68 65 20 72 65 73 75 6c  74 2c 20 61 6e 64 20 74  |he result, and t|
00000d00  68 65 20 6e 75 6d 62 65  72 20 6f 66 20 74 65 72  |he number of ter|
00000d10  6d 73 20 75 73 65 64 20  74 6f 20 70 72 6f 76 69  |ms used to provi|
00000d20  64 65 20 74 68 65 20 61  70 70 72 6f 78 69 6d 61  |de the approxima|
00000d30  74 69 6f 6e 20 63 61 6e  20 62 65 20 61 6c 74 65  |tion can be alte|
00000d40  72 65 64 20 62 79 20 63  68 61 6e 67 69 6e 67 20  |red by changing |
00000d50  74 68 65 20 66 6f 6c 6c  6f 77 69 6e 67 20 76 61  |the following va|
00000d60  72 69 61 62 6c 65 73 20  61 74 20 74 68 65 20 62  |riables at the b|
00000d70  65 67 69 6e 6e 69 6e 67  20 6f 66 20 74 68 65 20  |eginning of the |
00000d80  70 72 6f 67 72 61 6d 3a  2d 0a 0a 69 74 25 3d 20  |program:-..it%= |
00000d90  74 68 65 20 6e 75 6d 62  65 72 20 6f 66 20 69 74  |the number of it|
00000da0  65 72 61 74 69 6f 6e 73  20 28 69 6e 69 74 69 61  |erations (initia|
00000db0  6c 6c 79 20 31 30 30 29  0a 61 63 63 32 25 20 3d  |lly 100).acc2% =|
00000dc0  20 74 68 65 20 61 63 63  75 72 61 63 79 20 6f 66  | the accuracy of|
00000dd0  20 74 68 65 20 72 65 73  75 6c 74 20 28 69 6e 69  | the result (ini|
00000de0  74 69 61 6c 6c 79 20 31  30 30 29 0a 0a 0a 20 2a  |tially 100)... *|
00000df0  2a 2a 2a 2a 2a 2a 2a 2a  2a 2a 2a 2a 2a 2a 2a 2a  |****************|
*
00000e40  2a 2a 2a 2a 2a 2a 2a 2a  2a 2a 2a 2a 0a 20 2a 2a  |************. **|
00000e50  20 74 68 65 20 6e 75 6d  62 65 72 20 27 65 27 20  | the number 'e' |
00000e60  6c 69 73 74 65 64 20 74  6f 20 31 39 39 30 20 64  |listed to 1990 d|
00000e70  65 63 69 6d 61 6c 20 70  6c 61 63 65 73 20 69 6e  |ecimal places in|
00000e80  20 63 6f 6e 74 61 69 6e  65 64 20 69 6e 20 74 68  | contained in th|
00000e90  65 20 66 69 6c 65 20 27  65 27 20 2d 20 74 68 65  |e file 'e' - the|
00000ea0  20 70 72 6f 67 72 61 6d  20 2a 2a 0a 20 2a 2a 20  | program **. ** |
00000eb0  74 6f 6f 6b 20 6a 75 73  74 20 75 6e 64 65 72 20  |took just under |
00000ec0  32 34 20 68 6f 75 72 73  20 74 6f 20 63 61 6c 63  |24 hours to calc|
00000ed0  75 6c 61 74 65 20 61 6c  6c 20 32 30 30 30 20 74  |ulate all 2000 t|
00000ee0  65 72 6d 73 20 74 6f 20  6e 65 61 72 6c 79 20 32  |erms to nearly 2|
00000ef0  30 30 30 20 64 65 63 69  6d 61 6c 20 70 6c 61 63  |000 decimal plac|
00000f00  65 73 20 20 20 20 20 20  2a 2a 0a 20 2a 2a 2a 2a  |es      **. ****|
00000f10  2a 2a 2a 2a 2a 2a 2a 2a  2a 2a 2a 2a 2a 2a 2a 2a  |****************|
*
00000f60  2a 2a 2a 2a 2a 2a 2a 2a  2a 0a 0a                 |*********..|
00000f6b