SuivantPrec.Bas prec.BasNiv. sup.

Chapter 6 Intrinsic operators 

The following operators are built-in (I will call them 'intrinsic' from now on in contrast to the 'functions'). They are discussed in detail now.
+ The + operator adds its arguments, if they are real numbers. If at least one string takes part in the operation, a con- catenation is performed. Some examples

1+1 2
1.5+1 2.5
1+'a' '1a'
'abc'+'def''abcdef'
'a '+' b' 'a b'
'+'+'+' ++
- The - operator subtracts its arguments, if they are real numbers. If at least one string takes part in the operation, a replacement is performed. If the statement is s1-s2, all occurences of s2 in s1 are removed. Some examples:

1-1 0
1.5-1 0.5
1-'a' 1
'abc aba'-a'bc b'
'-'-'-' "
* This operator multiplies its arguments, if they are numbers, otherwise '?' is returned. Some examples:

1*1 1
1.5*2.5 3.75
1*'a' ?
'abc'*' '?
/ divides the arguments, if they are both numbers. If one of the arguments is not a number, or if the second number is zero, '?' is returned. Examples:

1/1 1
1.5/2.5 0.6
1/'a' ?
'abc'/' '?
div performs an integer division of the arguments. If one of them is not a number or the second argument is zero, '?' is returned. Note that reals are rounded according to ASETs type concept.

1 div 1 1
10 div 3 3
10.5 div 3.1 3(= 11 div 3)
10.5 div 3.5 2(= 11 div 4)
100a div 100?
'ab' div ' ' ?
mod, % apply the mod function to the arguments. If one of them is not a number or the second argument is zero, '?' is returned. Note that reals are rounded according to ASETs type concept. The '%' character is interpreted as a shell variable reference in most DOS versions. Therefore you must use '%%' (or div, of course) there. Some examples:

1%1 0
10 mod 3 1
10.5 mod 3.12(= 11 mod 3)
10.5%3.5 3(= 11 mod 4)
100a%100 ?
'ab'%' ' ?
^, ** raise the first argument to the power of the second. These operators determine whether the exponent is integer or not and choose the most efficient algorithm for the computation. They return '?' if at least one non-real is involved or an error occurs. An error occurs if the exponent is not an integer and the first argument is less than zero. Examples:

2^3 8
2.5^2 6.25
9**0.53
-1^2 1
-1^2.5 ?
a^1 ?
abc^' ' ?
eq, =, == test if the arguments are equal. The equality is checked in a different way for the different data types. If both arguments are integers, the numbers are checked. If both are reals, the numbers are checked using a built-in constant EPS (whose value is returned by the generic function EPS). The check which is performed, is "abs(r1 - r2) < EPS", ie. the so-called absolute error is checked. For strings the check is about literal equality (each character must correspond). The return value is boolean, ie. 1, if true, 0, if false. Some examples:

9==09 1(integers)
'9'=='09' 1(still integers)
'a'=='A' 0(case is relevent)
'a bc'='a bc' 1(of course)
1.2 eq 1.3 0(EPS is not THAT big)
1.2 eq 1.200000011(big enough for this)
ne, != The opposite of eq, making the same assumptions. Examples:

9!=09 0
'9'!='09' 0
'a'!='A' 1
'a bc'!='a bc' 0
1.2 ne 1.3 1
1.2 ne 1.200000010
lt, gt, le, ge Self explanatory.
and, or, nand, nor, xor are the logical operators. Their meaning is defined in two different ways, depending on the type of the arguments. If both are boolean, the result is computed as if the values true and false took part in the operation. If both are integer (which includes one integer and one boolean), the arguments are processed bitwise. Real numbers and strings result in '?'. Some examples:

1 and 1 1 (boolean)
1 and 2 0 (integer)
1 and 3 1 (integer)
a and 1 ?
1.2 and 0?
SuivantPrec.Bas prec.HautNiv. sup.