Recent Changes - Search:
Email iofreak@yahoo.com with comments and/or suggestions.

Aibo General

Aibo Development

Wiki Help

Aibo Links

R-Code » Math

Math Statements

Perform arithmetic operations.

Models

ERS-210 ERS-220 ERS-31x ERS-7

OperationSyntaxEquivalent Math Expression
AdditionADD:var:valuevar = var + value
SubtractionSUB:var:valuevar = var - value
MultiplicationMUL:var:valuevar = var * value
DivisionDIV:var:valuevar = var / value
Modulus (Remainder)MOD:var:valuevar = The remainder from var / value
Random NumberRND:var:min:maxvar = A random number between min and max

Example(s)


   LOCAL:x   // declare a local variable x
   LET:x:1   // x = 1
   MUL:x:10  // x = x * 10
   ADD:x:1   // x = x + 1
   PRINT:"x = %d":x // output x = 11
 

Remarks

The random number seed is specified by SET:Seed:value

In addition to the above variable-based math operations, stack-based math operations are available. In general, stack-based math is performed by PUSHing operands onto the stack, then calling the desired operation. The operand values will be POPed off the stack, with the result of the operation PUSHed back to the stack.

   PUSH:operand1
   PUSH:operand2
   operation
   POP:result   // result = operand2 operation operand1

OperationSyntaxEquivalent Math Expression
AdditionADDoperand1 + operand2
SubtractionSUBoperand1 - operand2
MultiplicationMULoperand1 * operand2
DivisionDIVoperand1 / operand2
Modulus (Remainder)MODThe remainder from operand1 / operand2

Math statement syntax has the following parts:

PartDescription
varThe user defined Variable name.
valueVariable name or constant.
minVariable name or constant.
maxVariable name or constant.
operand1-2Variable name or constant.
resultVariable name or constant.

Example(s)


   LOCAL:x   // declare a local variable x
   LET:x:1   // x = 1
   PUSH:10   // place 10 on the stack
   PUSH:x    // place the value of x on the stack
   MUL       // stack value is now x * 10
   PUSH:1    // place 1 on the stack 
   ADD       // stack value is now 10 + 1
   POP:x     // x = top of stack
   PRINT:"x = %d":x // output x = 11
 

Edit - History - Print - Recent Changes - Search - Site Terms of Use
Page last modified on September 03, 2006, at 02:17 PM CST