15.16.2
Division Operator
/
EXPRESSIONS
In the remaining cases, where neither an infinity or NaN is involved, the prod
uct is computed. If the magnitude of the product is too large to represent, we
say the operation overflows. The result is then an infinity of appropriate sign.
If the magnitude is too small to represent, we say the operation underflows;
the result is then a zero of appropriate sign. Otherwise, the product is rounded
to the nearest representable value using IEEE 754 round to nearest mode. The
Java language requires support of gradual underflow as defined by IEEE 754
( 4.2.4).
Despite the fact that overflow, underflow, or loss of information may occur,
evaluation of a multiplication operator
*
never throws a run time exception.
15.16.2 Division Operator
/
Gallia est omnis divisa in partes tres.
Julius Caesar,
Commentaries on the Gallic Wars
(58 B.C.)
The binary
/
operator performs division, producing the quotient of its operands.
The left hand operand is the dividend and the right hand operand is the divisor.
Integer division rounds toward
0
. That is, the quotient produced for operands
n
and
d
that are integers after binary numeric promotion ( 5.6.2) is an integer
value
q
whose magnitude is as large as possible while satisfying
d
q
n
;
moreover,
q
is positive when
n
d
and
n
and
d
have the same sign, but
q
is neg
ative when
n
d
and
n
and
d
have opposite signs. There is one special case that
does not satisfy this rule: if the dividend is the negative integer of largest possible
magnitude for its type, and the divisor is
1
, then integer overflow occurs and the
result is equal to the dividend. Despite the overflow, no exception is thrown in this
case. On the other hand, if the value of the divisor in an integer division is
0
, then
an
ArithmeticException
is thrown.
The result of a floating point division is determined by the specification of
IEEE arithmetic:
If either operand is NaN, the result is NaN.
If the result is not NaN, the sign of the result is positive if both operands have
the same sign, negative if the operands have different signs.
Division of an infinity by an infinity results in NaN.
Division of an infinity by a finite value results in a signed infinity. The sign is
determined by the rule stated above.
Division of a finite value by an infinity results in a signed zero. The sign is
determined by the rule stated above.
352
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved