mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Release calc version 2.10.2t30
This commit is contained in:
102
help/types
Normal file
102
help/types
Normal file
@@ -0,0 +1,102 @@
|
||||
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.
|
Reference in New Issue
Block a user