15.16.3
Remainder Operator
%
EXPRESSIONS
Examples:
5%3
produces
 2
(note that
 5/3
produces
 1
)
5%( 3)
produces
 2
(note that
 5/( 3)
produces
  1
)
( 5)%3
produces
  2
(note that
 ( 5)/3
produces
  1
)
( 5)%( 3)
produces
  2
(note that
 ( 5)/( 3)
produces
 1
)
The result of a floating point remainder operation as computed by the
%
 oper 
ator is
not
 the same as that produced by the remainder operation defined by IEEE
754. The IEEE 754 remainder operation computes the remainder from a rounding
division, not a truncating division, and so its behavior is
not
 analogous to that of
the usual integer remainder operator. Instead, the Java language defines
%
 on float 
ing point operations to behave in a manner analogous to that of the Java integer
remainder operator; this may be compared with the C library function
fmod
. The
IEEE 754 remainder operation may be computed by the Java library routine
Math.IEEEremainder
 ( 20.11.14).
The result of a Java floating point remainder operation is determined by the
rules of IEEE arithmetic:
If either operand is NaN, the result is NaN.
If the result is not NaN, the sign of the result equals the sign of the dividend.
If the dividend is an infinity, or the divisor is a zero, or both, the result is NaN.
If the dividend is finite and the divisor is an infinity, the result equals the divi 
dend.
If the dividend is a zero and the divisor is finite, the result equals the dividend.
In the remaining cases, where neither an infinity, nor a zero, nor NaN is
involved, the floating point remainder
r
 from the division of a dividend
n
 by a
divisor
d
 is defined by the mathematical relation
r
=
n
(
d
q
)
 where
q
 is an
integer that is negative only if
n
d
 is negative and positive only if
n
d
 is
positive, and whose magnitude is as large as possible without exceeding the
magnitude of the true mathematical quotient of
n
 and
d
.
Evaluation of a floating point remainder operator
%
 never throws a run time
exception, even if the right hand operand is zero. Overflow, underflow, or loss of
precision cannot occur.
Examples:
5.0%3.0
produces
 2.0
5.0%( 3.0)
produces
 2.0
( 5.0)%3.0
produces
  2.0
( 5.0)%( 3.0)
produces
  2.0
354






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java hosting

 

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