bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java Math round() Method

❮ Math Methods

Example

System.out.println(Math.round(0.60));
System.out.println(Math.round(0.40));
System.out.println(Math.round(5));
System.out.println(Math.round(5.1));
System.out.println(Math.round(-5.1));
System.out.println(Math.round(-5.9));

Definition and Usage

The round() method rounds a number to the nearest integer.

One of the following

public static long round(double
number )
public static int round(float
number )

Parameter Values

ParameterDescription
numberRequired. A number to round.

Technical Details

Returns:A long value (if the argument is double) or int (if the argument is float) value representing the nearest integer to a number.
Java version:Any

Previous

Java Math rint() Method

Next

Java Math scalb() Method