Math Expressions

The math expressions in MAXScript correspond to the common operator expressions in mathematics, such as add, subtract, multiply, divide, and so on. The <math_expr> constructs in MAXScript are:

<math_operand> + <math_operand> -- standard arithmetic addition 
<math_operand> - <math_operand> -- standard arithmetic subtraction
<math_operand> * <math_operand> -- standard arithmetic multiplication
<math_operand> / <math_operand> -- standard arithmetic division
<math_operand> ^ <math_operand> -- exponential, raise to the power
<math_operand> as <class> -- conversion between types

where <math_operand> can be one of:

<operand>
<function_call>
<math_expr>
Note: A math operand can be another nested math expression. This is another instance of a recursive syntax definition which lets you create arbitrary sequences of operands and operators. Note also that the math unary minus is not defined here, it is one of the <operand> types described in Operands.

EXAMPLES:

   42
   2 + 2
   2 * a - sin x / b -- using a function call
   (a + b) * -c
   2 ^ n
   (n + 1) as string -- converts result to a string value

The conversion operator, as, works between selected sets of source and destination value types. Only certain kinds of values can be converted into certain other kinds of values. These allowed conversions are defined for each type of value, and are documented with the value type descriptions.