Java rint() Method
The rint() method returns the integer value closest to the argument.
Syntax
This method has the following syntax formats:
double rint(double d)
Parameters
- double type data.
Return Value
Returns a double value that is the integer closest to the argument.
Example
Example
public
class
Test
{
public
static
void
main
(
String
args
[
]
)
{
double
d
=
100
.675
;
double
e
=
100
.500
;
double
f
=
100
.200
;
System
.
out
.
println
(
Math
.
rint
(
d
)
)
;
System
.
out
.
println
(
Math
.
rint
(
e
)
)
;
System
.
out
.
println
(
Math
.
rint
(
f
)
)
;
}
}
Compile the above program; the output is:
101.0
100.0
100.0
The Java Number class