![QSI QTERM-R55 User Manual Download Page 17](http://html1.mh-extra.com/html/qsi/qterm-r55/qterm-r55_user-manual_3304037017.webp)
QTERM-R55 User's Manual
7
QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770
(2.71828) which comes as a predefined variable named
euler
. The exponentiation functions are illustrated by the
second qaBASIC example.
2.3.2.3
Integer and Fractional Parts
The functions
int()
and
frac()
split their argument at
the decimal point (see Example 2).
int
drops the fractional
portion of the argument and returns an integer.
frac
returns just the fractional portion of the argument.
2.3.2.4
Remainder
To get the remainder of a division use the
mod()
function.
As Example 2 shows,
mod(11,4)
produces
3
, because
11/4 = 2 with a remainder of 3.
NOTE: Arithmetic operations using large numbers may
cause fractional inconsistencies in your answer. For exam-
ple, 12000000 / 300000 may yield 40.00000001. This is
inherent in floating point arithmetic.
2.3.2.5
Minimum and Maximum
The functions
min()
and
max()
return the lower and
higher value of their two arguments respectively (see
Example 2).
2.3.2.6
Square Root
The square root is calculated by the
sqrt()
function (see
2.4
String Operations
BASIC has always been simple and strong in string pro-
cessing. qaBASIC also maintains this feature.
Example 3:
a$="123456"
print len(a$)
print left$(a$,2),"-";
print mid$(a$,2,3),"-";
print right$(a$,3)
left$(a$,2)="abcd":print a$
print str$(12)
print str$(12.123455,"%08.5f")
print 2+val("23")
print val("e2")
instr("Hallo","al")
lower$("aBcD12fG")
ltrim$(" foo ")
print asc("e")
This program produces the following output:
6
12-234-456
ab3456
12
12.12346
25
0
2
abcd12fg
"foo "
101
2.4.1
Length of a String
The
len()
function returns the length of the string (see
2.4.2
Extracting Parts of a String
There are three functions which return parts of a string:
left$(<string>,<length>)
right$(<string>,<length>)
mid$(<string>,<position>,<length>)
left$()
returns the leftmost <length> characters of
<string>.
right$()
returns the rightmost <length> char-
acters of <string>, and
mid$()
cuts in the middle, return-
ing <length> number of characters starting at <position>
characters from the left end of <string>. The first character
of a string is at position 1.
Furthermore,
left$()
and its associated functions can
even be used to selectively change parts of a string by
assigning a string to the function. Example 3 shows that
only the two leftmost characters are changed (even though
the string
"abcd"
contains four characters). The same can
be done with
mid$()
or
right$()
.
2.4.3
Strings to Numbers (and Numbers to Strings)
The str
$
( ) converts its numeric argument to a string (see
conversion of
12
in Example 3).
Formatting of the number is optionally specified by a sec-
ond argument (
"08.5f"
in Example 3). The second argu-
ment is essentially a format string as used by the
printf()
function in the C programming language. A subset of this
function is supported by the QTERM-R55.
Format:
str$ (value, "%Flagfieldwidth.
PrecisionArgument")