It may be that my references to 'BASIC syntax' might not mean much to some people.
It used to be that every small computer came equipped with BASIC but, as this has not been the case for some years now, I felt it might be useful to give a brief outline of the BASIC syntax you need to use to enter equations for the 'function' command or to create expressions for a program or command.
BASIC is an acronym for Beginners All-purpose Symbolic Instruction Code and it is the language that most of us over 50 cut our programming teeth on. Over 60 and you were likely to have started programming in binary via a set of switches!
The operators and functions which you can use are listed below. They are all case sensitive.
|^||Raise to the power|
|/||Fractional, floating point division|
|+||Addition or a positive value|
|-||Subtraction or a negative value|
|>||Greater than *|
|<||Less than *|
|<>||Not equal to *|
|<=||Less than or equal to *|
|>=||Greater than or equal to *|
|and||Logical AND * |
|or||Logical OR * |
|xor||Logical Exclusive OR, XOR * |
|not||Logical NOT * |
|eqv||Logical equivalence, Not XOR * |
|imp||Logical implication * |
* The results of logical operations return -1 for True and 0 for False.
These operators can be applied to values as well as conditions.
Hover over the reference symbols for examples.
These operators can generate 1's from zeroes. As all of the bits in the number/s are processed, (32 bits in the case of integers), any leading zeroes in the values used will generate 1's and so the result is likely to be a negative number.
Hover over the symbols for examples.
|abs||Abs, the absolute value|
|exp||Exp, enumber, the antilogarithm|
|fix||Fix, = Sgn(number)*Int(Abs(number))|
|int||Int, the integer portion of the number|
|log||Log, the natural logarithm|
|rnd||Rnd, a random number where 0 £ number < 1|
|sgn||Sgn, sign of the number|
|sqr||Sqr, the positive square root|
|log10||Logarithm to the base 10|
|log2||Logarithm to the base 2|
Inverse Trig. Functions
|cot||1/Tan, cotangent, cotan|
|arcsin||'Angle whose sine is'|
|arccos||'Angle whose cosine is'|
|atn||'Angle whose tangent is', Arctan|
|arcsec||'Angle whose secant is'|
|arccosec||'Angle whose cosecant is'|
|arccot||'Angle whose cotangent is'|
With BASIC, the main rule is that everything has to be stated explicitly. e.g. we all know that 2x means "Two multiplied by x" but this has to be written in full as '2*x' in BASIC.
A second point is that, as all parts of an equation have to be entered in line, far more parentheses are needed than is the case with written algebra. An equation which would usually be written as "1 over 1 + x" has to be entered as 1/(1+x).
Whilst the following is a rule of basic arithmetic not BASIC, a common mistake is to misinterpret expressions such as 2 + 5 x 3 and expect the result '21' when, in fact, it's 17. [21 = (2 + 5) x 3].