mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Some folks might think: “you still use RCS”?!? And we will say, hey, at least we switched from SCCS to RCS back in … I think it was around 1994 ... at least we are keeping up! :-) :-) :-) Logs say that SCCS version 18 became RCS version 19 on 1994 March 18. RCS served us well. But now it is time to move on. And so we are switching to git. Calc releases produce a lot of file changes. In the 125 releases of calc since 1996, when I started managing calc releases, there have been 15473 file mods!
125 lines
5.2 KiB
Plaintext
125 lines
5.2 KiB
Plaintext
Builtin types
|
|
|
|
The calculator has the following built-in types.
|
|
|
|
null value
|
|
This is the undefined value type. The function 'null'
|
|
returns this value. Functions which do not explicitly
|
|
return a value return this type. If a function is called
|
|
with fewer parameters than it is defined for, then the
|
|
missing parameters have the null type. The null value is
|
|
false if used in an IF test.
|
|
|
|
rational numbers
|
|
This is the basic data type of the calculator.
|
|
These are fractions whose numerators and denominators
|
|
can be arbitrarily large. The fractions are always
|
|
in lowest terms. Integers have a denominator of 1.
|
|
The numerator of the number contains the sign, so that
|
|
the denominator is always positive. When a number is
|
|
entered in floating point or exponential notation, it is
|
|
immediately converted to the appropriate fractional value.
|
|
Printing a value as a floating point or exponential value
|
|
involves a conversion from the fractional representation.
|
|
|
|
Numbers are stored in binary format, so that in general,
|
|
bit tests and shifts are quicker than multiplies and divides.
|
|
Similarly, entering or displaying of numbers in binary,
|
|
octal, or hex formats is quicker than in decimal. The
|
|
sign of a number does not affect the bit representation
|
|
of a number.
|
|
|
|
complex numbers
|
|
Complex numbers are composed of real and imaginary parts,
|
|
which are both fractions as defined above. An integer which
|
|
is followed by an 'i' character is a pure imaginary number.
|
|
Complex numbers such as "2+3i" when typed in, are processed
|
|
as the sum of a real and pure imaginary number, resulting
|
|
in the desired complex number. Therefore, parenthesis are
|
|
sometimes necessary to avoid confusion, as in the two values:
|
|
|
|
1+2i ^2 (which is -3)
|
|
(1+2i) ^2 (which is -3+4i)
|
|
|
|
Similar care is required when entering fractional complex
|
|
numbers. Note the differences below:
|
|
|
|
3/4i (which is -(3/4)i)
|
|
3i/4 (which is (3/4)i)
|
|
|
|
The imaginary unit itself is input using "1i".
|
|
|
|
strings
|
|
Strings are a sequence of zero or more characters.
|
|
They are input using either of the single or double
|
|
quote characters. The quote mark which starts the
|
|
string also ends it. Various special characters can
|
|
also be inserted using back-slash. Example strings:
|
|
|
|
"hello\n"
|
|
"that's all"
|
|
'lots of """"'
|
|
'a'
|
|
""
|
|
|
|
There is no distinction between single character and
|
|
multi-character strings. The 'str' and 'ord' functions
|
|
will convert between a single character string and its
|
|
numeric value. The 'str' and 'eval' functions will
|
|
convert between longer strings and the corresponding
|
|
numeric value (if legal). The 'strcat', 'strlen', and
|
|
'substr' functions are also useful.
|
|
|
|
matrices
|
|
These are one to four dimensional matrices, whose minimum
|
|
and maximum bounds can be specified at runtime. Unlike C,
|
|
the minimum bounds of a matrix do not have to start at 0.
|
|
The elements of a matrix can be of any type. There are
|
|
several built-in functions for matrices. Matrices are
|
|
created using the 'mat' statement.
|
|
|
|
associations
|
|
These are one to four dimensional matrices which can be
|
|
indexed by arbitrary values, instead of just integers.
|
|
These are also known as associative arrays. The elements of
|
|
an association can be of any type. Very few operations are
|
|
permitted on an association except for indexing. Associations
|
|
are created using the 'assoc' function.
|
|
|
|
lists
|
|
These are a sequence of values, which are linked together
|
|
so that elements can be easily be inserted or removed
|
|
anywhere in the list. The values can be of any type.
|
|
Lists are created using the 'list' function.
|
|
|
|
files
|
|
These are text files opened using stdio. Files may be opened
|
|
for sequential reading, writing, or appending. Opening a
|
|
file using the 'fopen' function returns a value which can
|
|
then be used to perform I/O to that file. File values can
|
|
be copied by normal assignments between variables, or by
|
|
using the result of the 'files' function. Such copies are
|
|
indistinguishable from each other.
|
|
|
|
## Copyright (C) 1999 Landon Curt Noll
|
|
##
|
|
## Calc is open software; you can redistribute it and/or modify it under
|
|
## the terms of the version 2.1 of the GNU Lesser General Public License
|
|
## as published by the Free Software Foundation.
|
|
##
|
|
## Calc is distributed in the hope that it will be useful, but WITHOUT
|
|
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
|
## Public License for more details.
|
|
##
|
|
## A copy of version 2.1 of the GNU Lesser General Public License is
|
|
## distributed with calc under the filename COPYING-LGPL. You should have
|
|
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
|
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
##
|
|
## Under source code control: 1991/07/21 04:37:24
|
|
## File existed as early as: 1991
|
|
##
|
|
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
|
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|