Math.round()
Returns the nearest integer after rounding up .
Syntax
Math.round(double input_number)
Output is a rounded value.
System.out.println(Math.round(12.34)); //12
System.out.println(Math.round(12.67)); //13
System.out.println(Math.round(12)); //12
System.out.println(Math.round(-12.34)); //-12
System.out.println(Math.round(-12.67)); //-13
System.out.println(Math.round(-12)); //-12
Using double
double my_data=Math.round(12.34);
System.out.println(my_data); //12.0
« All Math functions
« Java
This article is written by plus2net.com team.
plus2net.com