Version 2.2 February 1999 S E X A G E S I M A L C A L C U L A T O R with T R I G O N O M E T R I C F U N C T I O N S (C) 1994/1999 Benno van Dalen To start the Sexagesimal Calculator switch to the directory that contains the file SCTR.EXE (e.g. the root directory of the disk on which you received the program) and type SCTR To leave the program press Q. After every session SCTR will save all decimal and sexagesimal numbers from stack and memory in a file called SAVE.SC (the concepts of stack and memory will be explained below). If the file SAVE.SC is not present or defective when the program is started, all numbers will be set to zero. If the program does not display properly, you may try to delete the file SAVE.SC and restart. The Sexagesimal Calculator with TRigonometric functions (to be called SCTR in the sequel) simulates a pocket calculator for sexagesimal numbers. It uses the so-called Reverse Polish System, which is applied in most Hewlett Packard calculators. All calcu- lations are performed using a LIFO (Last In First Out) stack. This stack contains four registers, called X, Y, Z and T, which are permanently displayed on the screen. A number can be pushed into register X of the stack by typing it in one of the forms recognized by the program (see below) and pressing . All other numbers on the stack will then be pushed downwards: the contents of register X is moved to register Y, Y to Z, Z to T, and the contents of register T is lost. Every unary operator (ChangeSign, Square Root, the trigonometric functions, etc.) is performed on the number in register X. Every binary operator is performed on the numbers in registers X and Y ( - subtracts X from Y, / divides Y by X). The result of a binary operator is stored in register X. The contents of registers Z and T will then move to Y and Z respectively; T remains unaltered. If you want to perform a command on a number that you have just entered, you need not type first. Instead you can type the desired command at once (e.g. 23;35 SI in order to calculate the sine of the sexagesimal number 23;35). Note that in the Reverse Polish System, contrary to the system used on most types of pocket calcutors, there is no = sign. Both operands of a binary operator must be entered before the operator can be specified. Brackets are superfluous because the four registers of the stack can be used to store intermediate results. For instance, (2+4*(5+6))/7 can be computed by pressing 2 4 5 SR 6 SQ + * + 7 / or, more efficiently, by 5 SR 6 SQ + 4 * 2 + 7 / DECIMAL AND SEXAGESIMAL MODES SCTR has two basic modes: sexagesimal and decimal. The sexagesimal mode provides sexagesimal numbers with 17 digits: 5 before and 12 after the sexagesimal point. [All calculations, including those of the trigonometric functions, are performed to an accuracy of 15 sexagesimal digits after the sexagesimal point. This implies that in practically all cases all digits displayed are correct.] The sexagesimal digits are separated by commas, the sexagesimal point is indicated by a semicolon. The decimal mode provides the Turbo Pascal extended type accurate to 18 or 19 digits. The two modes have their own stacks, memory locations and memory descriptions. Thus it is possible to perform commands on decimal numbers without losing previously entered or stored sexagesimal numbers, and vice versa. DECIMAL MODE is indicated by D. Decimal numbers have the form: 173.3331936 The accuracy of the decimal numbers is 18 or 19 digits. In SEXAGESIMAL MODE numbers have four possible forms: 1) plain sexagesimal (indicated by S): 1,20,45;34,56,0,30 2) Greek (indicated by G; the integer part of the number is displayed in decimals, the fractional part in sexagesimals): 4845;34,56,0,30 3) Zodiacal signs (indicated by Z; the integer part is displayed in rotations of 360 degrees, zodiacal signs of 30 degrees, and single degrees): 13r 5s 15;34,56,0,30 4) Chinese (indicated by C; the numbers are displayed in days, fens (a fen is a tenthousandth of a day), and sexagesimal fractions of fens): 4845d 1,37,2f 14,43,20 [Note that the number of fens is written sexagesimally. The Chinese numbers occur in sources related to Chinese astronomy, for instance in descriptions of the Chinese-Turkish calendar.] The four sexagesimal modes do NOT have their own stack and memory. In all four modes all commands will be carried out on the same stack and memory. The only difference between the modes is the way in which the numbers are displayed. You can switch between the four sexagesimal modes and decimal mode by means of the command ALT-M. It is possible to enter any type of number at any moment. If you type a decimal number in one of the sexagesimal modes, the calculator will automatically switch to decimal mode. If you type a sexagesimal number in decimal mode, the calculator will switch to the sexagesimal mode in which you have typed the number (with a preference for Greek mode). If you type a sexagesimal number in one of the four sexagesimal modes, the mode will not change; you have to change the mode explicitly by means of the command ALT-M). Conversion of sexagesimal numbers to decimal numbers and vice versa can be performed by means of the command ALT-V. If you want to use a single decimal number in a sexagesimal calculation, simply type the number in its decimal form and press ALT-V. The sexagesimal equivalent of the number will then be pushed onto the sexagesimal stack at once (the decimal form will meanwhile be pushed onto the decimal stack). There is no danger of pressing incorrect keys when entering numbers in any of the accepted forms. SCTR will simply refuse any incorrect character. EXAMPLES: In Z mode, you can type the plain sexagesimal number 23,44,56;30. As soon as you type (or specify a command) it will be displayed as 237r 5s 26;30. If you now type 1000.0 SR SCTR will display the decimal stack and memory, push the number 1000 onto the stack and replace it at once by its square root. IMPORTANT!!! Note that while entering a number you have to type a capital "C" in order to change the sign of the number and capital "R", "S", "D" and "F" in order to indicate "rotations", "zodiacal signs", "days" and "fens" respectively. If you type lowercase letters instead, these will be interpreted as the beginning of the command that must be performed on the number (e.g. COsine, ROund, SIne, Square Root, Down and Fractional part). SCTR has three help screens that list all available commands. F1 cycles through the help screens, F2 displays the screen with the most common commands, F3 displays the trigonometric functions, and F4 displays the less common commands (including the so-called "ALT operations"). All commands can be performed at any time; the help screens only serve as an aid to memory. All commands that require further input (e.g. the number of a memory location, the number of sexagesimal digits after which rounding must be performed, an option etc.) can be cancelled by pressing . The same holds for entering a number. Note that whenever additional input for a command is required, a prompt appears on the bottom line of the screen. UNARY OPERATORS CS changes the sign of the number in register X. For instance: 23;35 CS leaves the negative number -23;35 onto the stack. While entering the number, the sign can be changed by typing a capital "C". F replaces the number in register X by its fractional part after the specified sexagesimal or decimal position. RO rounds the number in register X to the specified number of sexagesimal or decimal positions. RE replaces X by its reciprocal (1/X). SQ replaces the number in register X by its square. SR replaces the number in register X by its square root. TR truncates the number in register X to the specified number of sexagesimal or decimal positions. BINARY OPERATORS + adds the numbers in registers X and Y and leaves the result in register X. The numbers in registers Z and T are moved upwards. - subtracts the number in register X from the the number in register Y. * multiplies the numbers in registers X and Y. / divides the number in register Y by the number in register X. RM leaves the remainder of the division Y / X in register X. STACK OPERATIONS D rolls the stack downwards (the contents of T moves to X, X to Y, etc.). Instead of D one may use the key. U rolls the stack upwards (the contents of Y moves to X, X to T, etc.). Instead of U one may use the key. X exchanges the contents of registers X and Y. Z removes the contents of register X. The numbers in the other registers move upwards. MEMORY OPERATIONS RC pushes the contents of the specified memory location onto the stack (RC stands for ReCall). ST stores the contents of register X in the specified memory location. The available memory locations are 0 to 9. At any time only three of the ten locations are visible. If you want to view the other locations, use the scroll memory commands ALT-S and ALT-T. Note that there are separate memory locations for sexagesimal and decimal mode. ALT-C cancels the description of the specified memory location. Instead of the description the number in the memory loca- tion will be displayed again (except when it equals zero). Use ALT-S or ALT-T to view the contents or descrip tions of all memory locations. ALT-D gives the possibility to enter a description (at most 55 characters) of a number in a memory location. The program asks for the location for which you want to give a descrip- tion and then shows a prompt (:) to indicate that you can type the desired text. The description will be shown in the memory window instead of the number it describes. Note that there are separate memories, and therefore also separate descriptions, for sexagesimal and decimal mode. ALT-S scrolls the memory upwards. ALT-T scrolls the memory downwards. TRIGONOMETRIC FUNCTIONS CB changes the radius of the base circle for the trigonometric functions. The user is requested to type the new radius on the bottom line of the screen. Numbers between 1 and 9999 are accepted. CD assumes that the number in the X register denotes an angle in radians and replaces it by the corresponding number of degrees. CR assumes that the number in the X register denotes an angle in degrees and replaces it by the corresponding number of radians. RD changes the trigonometric mode from radians to degrees or vice versa. In radian mode all angles are assumed to be in radians, in degree mode all angles are assumed to be in degrees. The following trigonometric functions produce different results depending on the trigonometric mode (Radians or Degrees, to be toggled by means of the command RD described above) and on the radius of the base circle (to be changed by means of the command CB). CH replaces the contents of register X by its chord. CO replaces X by its cosine. SI replaces X by its sine. TA replaces X by its tangent. ACH replaces X by the number of which X is the chord (the "arc chord". ACO replaces X by its arc cosine. ASI replaces X by its arc sine. ATA replaces X by its arc tangent. M replaces X by X MOD 360 or X MOD 2ã, depending on the trigo- nometric mode. This command can be particularly useful when calculating planetary longitudes. Note that the result is always a number between 0 and 360 (or between 0 and 2ã), e.g. -60 MOD 360 = +300. P pushes the number pi (ã ÷ 3.14... ÷ 3;8,...) onto the stack. VARIOUS COMMANDS Q quits the Sexagesimal Calculator. The contents of stacks and memory are automatically saved in the file SAVE.SC and will be loaded again when the program is started anew from the same directory. The writing and reading of the file SAVE.SC can be suppressed by starting the program with the option /n (SCTR /n); in that case the print command ALT-P will not be available either. ALT-M changes the mode in which the numbers are displayed. The program requests one of the five letters C, D, G, S and Z (see the description of the modes above). Note that it is also possible to switch from sexagesimal to decimal mode just by typing a decimal number, and vice versa. ALT-P prints the stack and / or memory of the current mode. The program expects one of four options: S (stack), M (memory without descriptions), D (memory with descriptions) or A (all, including the descriptions of the memory locations). When using a laser printer, you will have to press the form feed button on the printer to have the output printed. If SCTR is started with the /n parameter (SCTR /n) in order to suppress the use of the file SAVE.SC (see the description of the command Q), the Print command will not be available. ALT-V converts a sexagesimal number into a decimal number or vice versa. SCTR will automatically change from sexagesimal to decimal mode or the other way around. When a decimal number is converted the non-significant digits of the resulting sexagesimal number are filled with zeros. ALT-Z sets the contents of the stack and / or memory of the current mode to zero. The program expects one of the options: S (stack), M (memory including descriptions) or A (all). BUGS Although SCTR has been tested extensively, some errors may still be present. The author disclaims liability for damage that might be caused by such errors. If SCTR cannot be started, the format of the file SAVE.SC may be incorrect. In that case, the easiest solution is to delete that file, or to start SCTR with the /n parameter (SCTR /n). In incidental cases, a digit 60 may be displayed in the middle of a sexagesimal number (but see below under CHANGES). Millennium Bug: the only date related operation performed by SCTR is the setting of the date-and-time stamp on the configuration file SAVE.SC. This file, which keeps all decimal and sexagesimal numbers from stack and memory, is written to disk when SCTR is terminated. To write SAVE.SC to disk, SCTR calls the DOS routines (interrupts) concerned directly. Therefore, MM can be considered to be millennium proof. CHANGES BETWEEN VERSIONS 2.1 AND 2.2 Some minor changes were introduced in a new version (2.2) released in February 1999. These include: 1) An alternative screen display mode, which shows only the X register and five memory positions (instead of the whole stack plus three memory positions). This may be convenient for users who are being confused by seeing the whole stack or make intensive use of the memory. Use the function key F10 to change between the old and new display modes at any time. 2) A command line option which makes SCTR work on systems on which the video memory may not be accessed directly, such as graphical simulations of DOS (an example is the Japanese DOS-V). To avoid direct access of the video memory, use either the command line option /JP (for JaPanese) or /NFSA (No Fast Screen Access). 3) A bug was repaired, which occasionally left the mode in which numbers on the stack and in memory are displayed (sexagesimal or decimal) undefined and could then garble the screen. This happened, in particular, when applying two consecutive number conversions (ALT-V) from any sexagesimal mode. 4) A bug was repaired, which would occasionally display a digit 60 within a sexagesimal number, for example 300760 / 365 = 823;60. Apparently this bug only occurred in versions of SCTR which were compiled on a machine with a Pentium processor, not with a 80486. 5) The colour of the input line at the bottom of the screen was changed to green, so that it is more obvious that input is expected for certain commands (e.g., the number of sexagesimal digits for RO, F, TR; the number of a memory location for ST, RC, ALT-D, ALT-C; the mode in which numbers are displayed for ALT-M; etc.). MEMORY RESIDENT VERSION SCTR also has a so-called "memory resident version" SCTR_TSR. This version can be loaded into memory by simply typing SCTR_TSR and will remain there until it is removed by typing SCTR_TSR /r (the "r" stands for release). In the meantime it can be called from within many other programs by pressing the so-called "hot key" SHIFT-ALT-S (press the SHIFT, ALT and S keys simultaneously). SCTR will then "pop up" and can be used in the ordinary way to perform any sexagesimal calculations. After pressing "Q" to leave SCTR, the computer will return to the program from which SCTR was called and the work in that program can be continued as if no interruption had occurred. Like in the ordinary version of SCTR, all decimal and sexagesimal numbers on the stack and in memory will still be present when the hot key is pressed anew. The resident version works from within most ordinary programs that do not use graphics, in par- ticular from within many word processors. It does not work under Windows, but there SCTR could be run in a separate (DOS) window and could be reached from other programs by switching windows. ADDRESS OF THE AUTHOR I would much appreciate comments or suggestions you might have concerning either SCTR or this manual. My permanent address is: Benno van Dalen Institut fuer Geschichte der Naturwissenschaften Postfach 111932 (FB 13) 60054 Frankfurt am Main Germany