Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Java rint() Method

Java rint() Method

Java Number ClassThe Java Number class


The rint() method returns the integer value closest to the argument.

Syntax

This method has the following syntax formats:


double rint(double d)

Parameters

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

Java Number ClassThe Java Number class