Java examples for Language Basics:Math
Round float and double numbers using Math.round
public class Main { public static void main(String[] args) { System.out.println(Math.round(10f)); // w w w.j a v a 2 s. c o m System.out.println(Math.round(1.5f)); System.out.println(Math.round(120.5f)); System.out.println(Math.round(-129.4f)); System.out.println(Math.round(-123.5f)); } }