Java rint() Method

Java Number类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

  • 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 and the output result is:

101.0
100.0
100.0

Java Number类Java Number Class

Other Extensions