Multiply (*) (Operator/multiplicative)

Multiply one operand by another.

Availability:

ECMAScript edition - 2
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Netscape Enterprise Server version - 2.0
Opera - 3.0
Property/method value type:Number primitive
JavaScript syntax:-anOperand1 * anOperand2
Argument list:anOperand1A value to be multiplied
anOperand2The multiplier value

The * operator performs multiplication, producing the product of its operands.

The multiplication is commutative. That means the operands being multiplied together can be arranged in any order without affecting the outcome as long as they are at the same precedence level. However, the multiplication may not always be associative in ECMAScript compliant interpreters due to finite precision in the evaluations. This means that placing parentheses around the operands may affect the outcome.

For example (A * B) * C may not evaluate identically to A * (B * C) to associative artifacts but A * B * C should be identical to B * C * A because of commutation.

The rules of floating point multiplication should be governed by the rules of IEEE 754 double-precision arithmetic.

If either operand is NaN then the result will be NaN.

The sign of the result is positive if both operands have the same sign, negative if the operands have different signs.

Multiplication of an infinite value by zero results in NaN.

Multiplication of infinity by infinity results in infinity. The sign is determined by the sign rules as normal.

Multiplying infinity by a finite non-zero value results in a signed infinity. The sign is determined as normal.

Otherwise, where neither an infinite value or NaN is involved, the product is computed and rounded to the nearest representable value. If the magnitude of the result is larger than the largest value the interpreter can cope with, an infinity of the appropriate sign is substituted. If the magnitude is too small to be represented, then a zero value is substituted.

Note that internally, zero values can be negative or positive and the sign may affect the result of subsequent computations.

The associativity is left to right.

Refer to the operator precedence topic for details of execution order.

See also:Associativity, Multiplicative operator, Multiply then assign (*=), Operator Precedence

Cross-references:

ECMA 262 edition 2 - section - 11.5.1

ECMA 262 edition 2 - section - 11.13

ECMA 262 edition 3 - section - 11.5.1