| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
$M) The Arithmetic command allows simple arithmetic between Cogsys variables.
This command is used to perform simple integer arithmetic on two numbers (either variables or constants) and then store the result in a Cogsys variable. The operators allowed in the $M command are:
+
-
*
/
\
Note that Cogsys variables are stored as signed long integers; an operation with a result that exceeds 2,147,483,647 will yield an invalid negative number as a result, and similarly for underflow.
Also note that in the case of divide-by-zero (and modulus-zero), the value returned will be -1,073,741,825.
$M
$Mvdest=value1opvalue2
@CPress any key to enter two integer values to add, subtract, multiply, divide, and modulus (\$M)#R Enter first integer number (V10): $GV10 Enter second integer number (V11): $GV11 $MV12=V10+V11 $SV10 + $SV11 = $SV12 $MV12=V10-V11 $SV10 - $SV11 = $SV12 $MV12=V10*V11 $SV10 * $SV11 = $SV12 $MV12=V10/V11 $SV10 / $SV11 = $SV12 $MV12=V10\V11 $SV10 \\ $SV11 = $SV12 Overflow example: $AV10=1 $AV11=0 $MV12=V10/V11 $SV10 / $SV11 = $SV12 Done. Press any key to exit.#R |
$MV12=12*4
V12
$MV12=V12+1
V12 by one