Availability: |
| ||||||||

Property/method value type: | Number primitive | ||||||||

JavaScript syntax: | - | * anOperand1anOperand2 | |||||||

Argument list: | anOperand1 | A value to be multiplied | |||||||

anOperand2 | The 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.

ECMA 262 edition 2 - section - 11.5.1

ECMA 262 edition 2 - section - 11.13

ECMA 262 edition 3 - section - 11.5.1

Prev | Home | Next |

Multiplicative operator | Up | Multiply then assign (*=) |

JavaScript Programmer's Reference, Cliff WoottonWrox Press (www.wrox.com)Join the Wrox JavaScript forum at p2p.wrox.comPlease report problems to support@wrox.com© 2001 Wrox Press. All Rights Reserved. Terms and conditions. |