Vanguard Software
Forecasting & Planning Solutions
Home Products Solutions Services Customers Partners Company
 
Applying science to business management

contents.gifindex.gifprev1.gifnext1.gif

Math Operators

Math operators are used to perform basic arithmetic calculation involving numbers. Almost all of these operators will accept real numbers, complex numbers, and matrices as operands.

The following sections describe the function of each operator.

Add x+y

The Add operator calculates the sum of x and y. The plus symbol can also be used to indicate the sign of a numeric literal (e.g., +5).

Subtract x-y

The Subtract operator subtracts y from x. The minus symbol is also used to enter negative numbers (e.g., -5).

Multiply x*y

The Multiply operator calculates the product of x and y.

Implied Multiply kx

Implied Multiply is not really an operator--instead it is the absence of an operator. For example, the expression 5x is treated the same as 5*x. In order to use the Implied Multiply function, k must be a numeric literal and x must be a variable, primitive, or node name.

Divide x/y

The Divide operator divides x by y.

Power x^y

The Power operator returns the value of x raised to the power y.

Percent x%

The Percent operator divides x by 100. For example, 25% is the same as 0.25.

Remainder x%y

The Remainder, or modulo, operator returns the remainder of dividing x by y. For example, 11%3 = 2. That is, 11 divided by 3 equals 3 with a remainder of 2. Although this operator is typically used with integer operands, it will accept floating-point values as well.

Increment x++, ++x

The Increment operator adds one to the variable x. If the ++ symbol appears before the variable (i.e. ++x) then Increment returns the value of x after being incremented. If the ++ symbol appears after the variable (i.e. x++) then x is still incremented, but Increment returns the value of x before adding one. For example,

var x=0,y;
y=x++;
watch(x,y); //
x = 1 and y = 0

var x=0,y;
y=++x;
watch(x,y); //
x = 1 and y = 1

The expression x must be a variable name, list element, or object property.

Decrement x--, --x

The Decrement operator works exactly like Increment, except that Decrement subtracts one from x instead of adding one.

Factorial x!

The Factorial operator calculates the value of x*(x-1)*(x-2)*...*1. For example 5! is the same as 5*4*3*2*1, which is equal to 120. The operand x must be an integer between 0 and 171.

  Demand Planning  |  Financial Forecasting
Forecasting Software  |  Strategic Planning Software  |  Decision Tree Software
Decision Support Software  |  Expert System Software  |  Online Surveys

Contact Us  |  Terms of Use  |  Privacy Policy  |  Site Map
Vanguard Software
© 2011 Vanguard Software Corporation
Print this page   Email this page to a friend