[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.3.1.5 Arithmetic ($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:

+
addition
-
subtraction
*
multiplication
/
division
\
modulus (remainder)

Note that Cogsys variables are stored as 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.

Name:
Arithmetic
Class:
Control
Code:
$M
Syntax:
$Mvdest=val1opval2
vdest is a variable reference
val1 and val2 are numbers
op is a character, must be one of `+', `-', `*', `/', `\'
System:
Cogsys performs the requested operation on the two numbers and stores the result in the variable vdest.

Test Files:
`MATH_T01.IN'
tests basic operation, including overflow example

Examples:

input
$MV12=12*4
cogsys
Assigns 48 (12 * 4) to variable V12

input
$MV12=V12+1
cogsys
Increments the value of variable V12 by one



This document was generated by Usman Muzaffar on June, 28 2000 using texi2html