Documentation for RPNMS.EXE March 19, 1992 This document applies to version 3.0 of RPNMS Copyright 1984-1992 by author Harry J Smith, Saratoga, CA INTRODUCTION (Note: See RPNM.DOC first for general introduction) To use the program type the name of the EXE file at the DOS prompt line with a return and no parameters. The program will load and respond with: *** RPNMS *** Version 3.0, Mar 19, 1992 Copyright (c) 1984-1992 by author: Harry J. Smith, 19628 Via Monte Dr., Saratoga, CA 95070. All rights reserved. Reverse Polish Notation Multiple-precision Scientific calculator Has a stack of four 8992 decimal digit numbers (3694 bytes) with a dynamic range of +/-9.9 ... 9 * 10 ** +/-39453 Press ESCAPE to interrupt a long calculation or a slow display Bytes in mantissa = 12 ( > 24 decimal digits) Max digits in display = 29552 Bytes to truncate in x for display = 2 Rounding is ON Base = 10 base ten, Max digit = 9 **** PRESS ANY KEY TO CONTINUE HELP OR PRESS ESCAPE **** n Enter a number, may not have a leading + or - sign ! X factorial " Start/stop comment field or file name "CC...C" * Multiply ** X = Y ** X Power (Integer part of X) + Add - Subtract / Divide 1/X X = 1.0 / X >DEG Convert X from radians to degrees >RAD Convert X from degrees to radians ? Display this help menu A Auto display on/off ABS Absolute value of X B Set base to X BEL Bell prompt on/off C Change sign of X CO Cosine CO- Arc-Cosine CL Clear X D Display X **** PRESS ANY KEY TO CONTINUE HELP OR PRESS ESCAPE **** DEG Set degree trig mode DL Display learned line E Enter X again ECHO Echo input to output, toggle on/off EP e to Power X EX Execute learned line EXX Execute X times FRAC Fractional portion of X I Interchange X and Y INT Integer portion of X L Last X LGE Enter Log e = 0.434... LN Natural Log (Base e = 2.718...) LN2 Enter Ln 2 = 0.693... LOG Common Log (Base 10) LOP Reduce precision of x by one byte LRN Learn N= Don't display = sign MMN Allow Max mantissa past accuracy of Pi etc. OFF Exit back to system ON Reinitialize **** PRESS ANY KEY TO CONTINUE HELP OR PRESS ESCAPE **** PI Enter Pi = 3.14... PO Rectangular to Polar coordinate conversion R Square Root R1 Recall memory register 1 R2 Recall memory register 2 RAD Set radian trig mode (nominal) RD Read and enter a number from file "CC...C" RE Polar to Rectangular coordinate conversion RN Generate a random number, 0.0 <= X < 1.0 RON Round results ROF Do not round results RRN Recall random number or seed S Square S1 Store X in memory register 1 S2 Store X in memory register 2 S<> Stop if X <> 0 S= Stop if X = 0 SD Set # of digits in display to X (1 - 29552) SG Set digits per group for output display of X SI Sine SI- Arc-Sine **** PRESS ANY KEY TO CONTINUE HELP OR PRESS ESCAPE **** SM Set # of bytes in mantissa to X (2 - 3694) SP Set spacing value, -1...3 SRN Set seed for random number to X ST Set # of bytes to truncate for display to X (0 - 3694) TA Tangent TA- Arc-Tangent U Rotate stack up (X -> Y -> Z -> T -> X) V Rotate stack down (X <- Y <- Z <- T <- X) WR Write register x into file "CC...C" Y= Display = sign YP Y to Power X [N] Don't display number of bytes in mantissa [Y] Display number of bytes in mantissa **** PRESS ANY KEY TO ENTER CALCULATOR MODE **** = 0.0 COMMAND: Commands may be entered one at a time followed by a return or several on a line separated by one or more spaces. A space is not required between commands if there is no ambiguity of meaning. Since this is an RPN calculator, 3 * (4 + 5) is entered as: 3 4 5 + * or 3 4 5+* or 4 5 + 3 * or 4 5+3* Be careful not to enter more than 4 items on the stack at any one time. The items on the stack are referred to as X, Y, Z, and T. X is the item on the bottom of the stack, Y is just above X, then Z above Y, and finally T is on the top. Operations that take two arguments to generate one, will pop X and Y off of the bottom of the stack, perform the operation, and push the result back onto the bottom of the stack. Such an operation will always result with Z and T being equal since when X is popped, T is duplicated into Z. The stack is always full. A push operation loses T. Operations that take only one argument will pop X, perform the operation, and push the result. When the program is loaded it determines how much internal memory is available for X, Y, X, T and the other long registers needed. It then makes these registers as long as possible to use up all available memory. The size of the decimal digit numbers on your system may be more or less than the indicated in the example above. This ends the introduction. I will now explain each command taking them in ASCII sort order. n Enter a number, may not have a leading + or - sign: Here n refers to keying in a number like 0 or 12345.6789. The number is merely pushed onto the stack. The way to enter a negative number is to enter its absolute value and then change its sign with the C command. Commas may be inserted in the number between any two digits to aid in reading. For example 12,345.678,9^-1,2 is a legal input number. ! X factorial: Replaces X with the factorial of X = 1 * 2 * 3 * ... * X. Only the integer portion of X is used in the calculation. " Start/stop comment field "CC...C": Comments can be entered at any time and are quite useful on the learned line, see LRN. The comment is started and ended with a " mark. All spaces between the " marks become part of the comment. Normally all commands are converted to upper case as they are input. The characters of a comment are not converted to upper case, they must be typed in upper case if upper case is desired. * Multiply: Pop X and Y, Push X times Y. ** X = Y ** X Power: Pop X and Y, Push Y to the power of X. Only the integer portion of the power X is used in the calculation. Use the YP command if the fractional part of X is to be used. + Add: Pop X and Y, Push sum of X and Y. - Subtract: Pop X and Y, Push Y minus X. / Divide: Pop X and Y, Push Y divided by X. 1/X X = 1.0 / X: Pop X, Push 1.0 divided by X. >DEG Convert X from radians to degrees: Multiplies X by 180 / Pi. >RAD Convert X from degrees to radians: Multiplies X by Pi / 180. ? Display this help menu: Causes the help menu to be displayed. It is the same as the menu displayed when you first enter the program, but the values currently set by the SM, SD, ST, RON, ROF, and B commands are displayed. A Auto display on/off: Normally, after each command line is executed, the contents of the bottom of the stack, X, is converted to the selected base and displayed. When computing with large numbers, the time spent in this conversion can be more than the time spent in the calculation. It is desirable then to be able to prevent this automatic display. Each time the A command is given the selection status of this option is reversed. ABS Absolute value of X: Forces the sign of X to be plus. The magnitude of X is unchanged. B Set base to X: Initially the base of both input and output display is set to ten. It can be changed at any time to a number between 2 and 36 decimal. If the base is ten, the command 36 B would Pop X and change the base to 36 base 10 and display: Base = 36 base ten, Max digit = Z Just as the digit F is worth fifteen when we are in base sixteen, the digit Z is worth thirty-five when we are in base thirty-six. Note that the value used to describe a base radix is always given in the normal decimal base, i.e. base ten. When in a base greater than ten, numbers may have to be entered with a leading 0 to prevent being mistaken for a command. When in base sixteen, a ten must be entered as 0A instead of A or the auto display status will be changed. A special case is made for getting back to base ten. If the X register is zero when the B command is given, X is popped from the stack and the base is set to ten. BEL Bell prompt on/off: This is good for timing long calculations. C Change sign of X: Same as multiplying X by minus one. The only way to enter a negative number is to enter its absolute value and then change its sign. CO Cosine: X is replaced with the cosine of X. All scientific functions are computed using the full precision currently set by the SM command. The RON and ROF commands can also affect the results of these functions. CO- Arc-Cosine: X is replaced with the arc-cosine of X. CL Clear X: X is set to zero. Y, Z and T are not affected. CL + can be used to perform a Pop operation. D Display X: This command is useful when the auto display is turned off. Also useful in the learned line to display intermediate results. DEG Set degree trig mode: The trigonometric functions, CO, CO-, PO, RE, SI, SI-, TA, and, TA-, normally assume the angle involved in either the input or output is expressed in radians. If degrees are desired use the DEG command. This mode stays selected until changed by the RAD command. DL Display learned line: Displays the current contents of the learned line. While commands may be given in either upper or lower case or even a mixture, the non-comment portion of the learned line is always displayed in upper case. E Enter X again: This duplicates X and Pushes it onto the stack. E E E will fill the stack with X. ECHO Echo input to output, toggle on/off: RPNMS allows for commands to be input from a disk file instead of the operator's keyboard. Also, the output can be directed to a disk file instead of the operator's console. This is done by entering at the DOS command line the following: A>RPNMS in-file-name >out-file-name Either or both fields may be present. When ECHO is off the input commands are not sent to the output file. Normally ECHO should be turned on with the first command of an input file. EP e to Power X: X is replaced with e ** X, where e is the base of the natural or Napierian logarithms. EX Execute learned line: This will cause the learned line to be executed once if there is no EX command in the learned line. Having LRN and/or EX in the learned line can produce interesting results. A simple case is a normal learned line with EX as its last command; this will cause the learned line to be repeatedly executed until the ESCAPE key is pressed. EXX Execute X times: This will Pop X and cause the learned line to be executed X times. X must be in the range 0 <= X <= 65535. FRAC Fractional portion of X: X is replaced with only the fractional portion of X by truncating the integer portion. I Interchange X and Y: Pop X, Pop Y, Push X, Push Y. INT Integer portion of X: X is replaced with only the integer portion of X by truncating the fractional portion. L Last X: On all computational operations (!, *, **, +, -, /, 1/X, >DEG, >RAD, B, CO, CO-, EP, FRAC, INT, LN, LOG, PO, RE, R, S, SD, SI, SI-, SM, ST, TA, TA-, and YP) the value of X is saved in LASTX, The L command retrieves LASTX and Pushes it onto the stack. This is quite useful in undoing an operation performed by mistake. It is one of the features that makes an RPN calculator desirable. LGE Enter Log e = 0.434...: Push the log base 10 of e onto the stack. LN Natural Log (Base e = 2.718...): X is replaced with the natural log of X. LN2 Enter Ln 2 = 0.693...: Push the natural log of 2 onto the stack. LOG Common Log (Base 10): X is replaced with the log base 10 of X. LOP Reduce precision of X by one byte: This command removes the least significant byte of X. If rounding is turned on, the removed byte is used to round into the new least significant byte. In RPNMS numbers are normalizes from both sides. If a calculation results in a number with some trailing zero bytes, these bytes are effectively removed by reducing the count of the number of bytes in the mantissa. The LOP command can result in a large number of bytes being removed if removing one byte results in a large number of trailing zeros. LRN Learn: This command stores all of the commands following on the same line as this one into the learned line. Execution of the current line is stopped. This line as well as all command lines are limited to 256 characters. Type the learned line: LRN N= 1 2 LRN 1 C SP D "! = " 1 SP * D L 1 + EX and then do two separate EX commands. You might want to key in a control-P after the second EX command just before you hit return to turn your printer on. This will print a table of factorials from 2! to 10943! or so, if you wait long enough. Hit the ESCAPE key twice to interrupt and abort the operation if you get tired of waiting. N= Don't display = sign: Normally displayed results are preceded with an = sign. This is handy so you can tell when a calculation is complete and the display conversion is being done. Aborting a display conversion with the ESCAPE key will not affect the value computed. If the = sign is not desired, the N= command can be given. MMN Allow Max mantissa past accuracy of Pi etc.: When the program is first loaded values for Log e, Ln 2 and Pi are read in from files LOGE.RPN, LN2.RPN and PI.RPN respectively. If these files cannot be found on the default drive, drive b: is also searched. The number of bytes in the mantissa of the number with the shortest mantissa of these three numbers is used to set the maximum mantissa allowed in the SM command. The number of bytes in the mantissa of these numbers is currently 1018 and these files are exactly 1024 bytes long. If it is desired to allow calculations with mantissas with more precision than the accuracy of the three constants, the MMN command can be given to extend the maximum precision to the limits of available memory. OFF Exit back to system: The program exits back to the operating system. ON Reinitialize: This totally reinitializes the program, the same as reloading from disk. Similar to the ? command except the parameters set by the B, ROF, RON, SD, SM, SRN, and ST commands are reset to their nominal values, and all registers are cleared. PI Enter Pi = 3.14...: Push the number pi onto the stack. PO Rectangular to Polar coordinate conversion: The X and Y registers are considered the rectangular coordinates of the 2-dimensional point (x, y) and are replaced with the corresponding polar coordinates of the same point. X becomes the radius and Y becomes the angle. R Square Root: X is replaced with the square root of X. R1 Recall memory register 1: Besides the stack and last X there are two memory registers that can hold any number that can be generated by this program. The R1 command will push the contents of the first of these registers onto the stack. R2 Recall memory register 2: The R2 command will push the contents of the second memory registers onto the stack. RAD Set radian trig mode (nominal): The trigonometric functions, CO, CO-, PO, RE, SI, SI-, TA, and, TA-, normally assume the angle involved in either the input or output is expressed in radians. If degrees are desired use the DEG command. When radians are desired use the RAD command. This mode stays selected until changed by the DEG command. RD Read and enter a number from file "CC...C": The RD command will use the last entered comment as a file name and read this file as a RPNMS formatted number and push it onto the stack. It is assumed that the file was created by the WR command. See the WR command for the format of file names. RE Polar to Rectangular coordinate conversion: The X and Y registers are considered the polar coordinates of a 2-dimensional point, the radius is in X and the angle is in Y. These are replaced with the corresponding rectangular coordinates (x, y) of the same point. RN Generate a random number, 0.0 <= X < 1.0: The RN command generates a random number between zero and 1.0 and pushes it onto the stack. This number will never have more than 80 significant bits. Theoretically the random number generator will cycle after 2 ** 80 numbers, but the earth will not last that long. RON Round results: This command sets rounding on. When rounding is on the results of all arithmetic operations are rounded to the maximum number of bytes in mantissa. Use the SM command to set the maximum number of bytes in mantissa. ROF Do not round results: This command sets rounding off. When rounding is off the results of all arithmetic operations are truncated to the maximum number of bytes in mantissa. Use the SM command to set the maximum number of bytes in mantissa. RRN Recall random number or seed: As random numbers are generated an 80 bit random integer is kept and used as the basis for the next random number. The RRN command pushes this value onto the stack. The value can be recorded at the end of a session and reentered with the SRN command at the beginning of a new session. This will prevent the same random number from ever being reused. Care must be taken to ensure that the number of bytes in mantissa is set to at least 10 and that the units portion of X is being displayed when the seed is recorded. S Square: X is replaced with the square of X. S1 Store X in memory register 1: Besides the stack and last X there are two memory registers that can hold any number that can be generated by this program. The S1 command will set the contents of the first of these registers to X. X remains unchanged. S2 Store X in memory register 2: The S2 command will set the contents of the second memory registers to X. X remains unchanged. S<> Stop if X <> 0: This command is useful in the middle of a learned line that is going to be executed repeatedly. It will cause the execution to stop if X is not zero. S= Stop if X = 0 : This command is useful in the middle of a learned line that is going to be executed repeatedly. It will cause the execution to stop if X is zero. SD Set # of digits in display to X (1 - 7360): The SD command will set the maximum number of digits to display to the current value of X, and then X is popped off the stack. If this is set larger than the accuracy implied by the number of bytes set by the SM command minus the number of bytes set by the ST command, the smaller value will be used to determine the number of digits to display. SG Set digits per group for output display of X: The SG command will set the number of digits per group to the current value of X, and then X is popped off the stack. If this is set to 3, numbers will be displayed with a comma after every 3rd digit like 1.234,567,89^34,457. If this is set to zero, 1 or 2, no commas will be displayed. SI Sine: X is replaced with the sine of X. SI- Arc-Sine: X is replaced with the arc-sine of X. SM Set # of bytes in mantissa to X (2 - 920): The SM command will set the maximum number of bytes in mantissa portion of any floating point value used in or resulting from any operation of the calculator. When this value is set to a smaller value than was currently set, all floating point values in the calculator are truncated to this number of bytes of precision in their mantissa. X is popped off the stack. SP Set spacing value, -1...3: Pops X and uses it to set the spacing value. The spacing value is initialized to two on start up which causes all output to be double spaced, one will cause single spacing, 0 causes a single blank character between outputs, and a -1 causes no space at all. SRN Set seed for random number to X: The SRN command stores the integer portion of the absolute value of X into the seed of the random number generator. As random numbers are generated an 80 bit random integer is kept and used as the basis for the next random number. The value can be recorded using the RRN command at the end of a session and reentered with the SRN command at the beginning of a new session. This will prevent the same random number from ever being reused. X remains unchanged. ST Set # of bytes to truncate for display to X (0 - 920): The ST command will set the number of bytes to truncate for display to the current value of X, and then X is popped off the stack. If the number of digits to display, set by the SD command is larger than the accuracy implied by the number of bytes set by the SM command minus the number of bytes set by the ST command, the smaller value will be used to determine the number of digits to display. TA Tangent: X is replaced with the tangent of X. TA- Arc-Tangent: X is replaced with the arc-tangent of X. U Rotate stack up (X -> Y -> Z -> T -> X): This is the same as a Push X except that T is also placed on the bottom of the stack and no stack items are lost. V Rotate stack down (X <- Y <- Z <- T <- X): This is the same as a Pop X except that X is also placed on the top of the stack and no stack items are lost. WR Write register X into file "CC...C": The WR command will use the last entered comment as a file name and write register X into this file as a RPNMS formatted number. This number can be reread into X by the RD command. If the file already exists it will be erased and recreated. For example, the following are valid file names: "file.ext" file.ext is on default drive, current user "b:filename.ext" filename.ext is on b: drive, current user "15/PI.RPN" PI.RPN is on default drive, user 15 "12/c:file.ext" file.ext is on c: drive, user 12 Y= Display = sign: (Note: Y stands for Yes not Y register) Normally displayed results are preceded with an = sign. This is handy so you can tell when a calculation is complete and the display conversion is being done. Aborting a display conversion with the ESCAPE key will not affect the value computed. If the = sign is not desired, the N= command can be given. When the = sign is again desired the Y= command is used. YP Y to Power X: Pop X and Y, Push Y to the power of X. Both the integer and fractional portions of X and Y are used in the calculation. Use the ** command if only the integer portion of the power X is to be used. [N] Don't display number of bytes in mantissa: It is some times desirable and instructive to know how many bytes are being used to represent a number in its internal binary format. This option to display this is selected by the [Y] command and deselected by the [N] command. For instance 1024 1/X will display as = 9.76562,5^-4 [1] if the option is selected. The number in brackets indicates that only one byte is being used to store the mantissa of 0.0009765625. The number of bytes is always displayed in decimal no matter what base is being used to display the number itself. [Y] Display number of bytes in mantissa: Select the option to display the count of the number of bytes being used to represent X in the internal binary format. See [N] above. Report any errors by writing me or call me at my home voice phone (408) 741-0406 evenings or weekends. Harry J. Smith 19628 Via Monte Dr. Saratoga, CA 95070

Return to Harry's Home Page

This page accessed times since October 20, 2004.

Page created by: hjsmithh@sbcglobal.net

Changes last made on Saturday, 14-May-05 12:43:36 PDT