996
|
1 Flonck, short for FLOating-point Numerical Calculator, is an INTERCAL
|
|
2 version of the classic reverse-polish calculator. All values are
|
|
3 entered and displayed as floating-point numbers. Entering a number
|
|
4 adds it to the top of the stack. The various operations are indicated
|
|
5 by integer number, and take their argument(s) off the top of the stack
|
|
6 and replace it/them with the result. Besides the main stack, flonck
|
|
7 also includes two separate "registers".
|
|
8
|
|
9 Note that this program requires the floating-point library in
|
|
10 lib/floatlib.i, which should be appended to flonck.i before compiling.
|
|
11
|
|
12 Here is the quick-reference chart of available operations:
|
|
13
|
|
14 ONE OH change sign TWO OH store in M
|
|
15 ONE add ONE ONE invert TWO ONE add to M
|
|
16 TWO subtract ONE TWO square root TWO TWO push M
|
|
17 THREE multiply ONE THREE ln TWO THREE exchange M
|
|
18 FOUR divide ONE FOUR exp TWO FOUR print M
|
|
19 FIVE remainder ONE FIVE x^y TWO FIVE store in N
|
|
20 SIX print ONE SIX pop TWO SIX add to N
|
|
21 SEVEN print all ONE SEVEN clear all TWO SEVEN push N
|
|
22 EIGHT duplicate ONE EIGHT int TWO EIGHT exchange N
|
|
23 NINE twiddle ONE NINE random TWO NINE print N
|
|
24 THREE OH quit
|
|
25
|
|
26 Functions ONE through FIVE should be self-explanatory. SIX displays
|
|
27 the topmost number on the stack without removing it. SEVEN displays
|
|
28 the entire stack, from top to bottom, again without changing anything.
|
|
29 EIGHT duplicates the topmost number, pushing an extra copy of it. NINE
|
|
30 causes the top two numbers on the stack to switch places.
|
|
31
|
|
32 The next few functions should be familiar to anyone who's used a
|
|
33 pocket calculator in recent memory. ONE OH multiplies the topmost
|
|
34 number by -1. ONE ONE divides the topmost number into 1. ONE TWO is
|
|
35 the square root function, ONE THREE is the natural logarithm function,
|
|
36 and ONE FOUR is the exponential function. ONE FIVE raises the topmost
|
|
37 number to the power of the next-topmost number. ONE SIX throws away
|
|
38 the topmost number, never to be seen again. ONE SEVEN wipes out the
|
|
39 entire stack and starts afresh. ONE EIGHT chops off the fractional
|
|
40 part of the topmost number. ONE NINE causes a randomly chosen number
|
|
41 between 0 and 1 to be added to the top of the stack.
|
|
42
|
|
43 The twenties are the functions that manipulate the two registers,
|
|
44 named M and N. (Both registers start out initialized to zero.) TWO OH
|
|
45 takes the topmost number off of the stack and stores it in M. TWO ONE
|
|
46 takes the topmost number off of the stack and adds it to whatever is
|
|
47 already in M. TWO TWO makes a copy of whatever is in M and adds it to
|
|
48 the top of the stack. TWO THREE swaps the contents of M with the
|
|
49 topmost number on the stack. TWO FOUR displays the contents of M
|
|
50 without changing it. Functions TWO FIVE through TWO NINE repeat the
|
|
51 above five functionalities for the register N.
|
|
52
|
|
53 And finally, as you might have guessed, writing (in) THREE OH causes
|
|
54 flonck to come to an end.
|
|
55
|
|
56 If an input does not correspond to a floating-point number or an
|
|
57 instruction, or if a function is input that requires more numbers on
|
|
58 the stack than currently exist, or if a function overflows or returns
|
|
59 an error, flonck prints out an error message, namely "XXX", and
|
|
60 continues. Note that in the latter case, the values used as function
|
|
61 arguments will still be removed from the stack.
|