Divide (/) (Operator/multiplicative)

Divide one operand by another.

Availability:

ECMAScript edition - 2
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Netscape Enterprise Server - 2.0
Opera - 3.0
Property/method value type:Number primitive
JavaScript syntax:-anOperand1 / anOperand2
Argument list:anOperand1The dividend
anOperand2The divisor

The left-hand operand is divided by the right-hand operand and the quotient is returned.

The left operand is the dividend, and the right is the divisor. ECMAScript compliant interpreters do not perform integer division. The operand and results of all divisions are double-precision floating point numbers. All divisions are performed according to IEEE 754 specifications.

If either operand is NaN then the result is NaN.

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

Division of an infinity by an infinity results in NaN.

Division of an infinity by zero results in an infinity. The sign is determined by the rule stated earlier.

Division of infinity by a non-zero finite value results in a signed infinity. The sign is determined as before.

Division of a finite value by infinity results in zero. The sign is determined as usual.

Division of a zero by a zero results in NaN.

Division of zero by any other finite value results in zero with the sign determined as normal.

Otherwise, where there is neither an infinity or zero involved and neither value is NaN, the quotient is computed and rounded to the nearest representable value. If the magnitude is too large to represent, it will overflow and become an infinity. If the magnitude is too small to represent, an underflow occurs and the result will be zero.

The associativity is from left to right.

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

See also:Associativity, Divide then assign (/=), Double-precision, Multiplicative expression, Multiplicative operator, Operator Precedence, Remainder (%)

Cross-references:

ECMA 262 edition 2 - section - 11.5.2

ECMA 262 edition 2 - section - 11.13

ECMA 262 edition 3 - section - 11.5.2