/**
 * {@link <a href=
 * "https://[Log in to view URL]"
 * target="_blank">arrotondamento per difetto</a>}
 * 
 * @author itammb ( Italia Massimiliano Buscati )
 * @version JDK 1.15
 *
 */
class Main {

    /**
	 * @see Math#ceil(double a)
	 * @see Math#floor(double a)
	 * @see Math#round(double a)
	 *
	 */
	public static void rounding() {
		// arrotonda con un valore maggiore (più piccolo) o uguale all'argomento
		System.out.println("1.1d -> " + Math.ceil(1.1d));
		System.out.println("1.5d -> " + Math.ceil(1.5d));
		System.out.println("1.8d -> " + Math.ceil(1.8d));
		System.out.println("2.0d -> " + Math.ceil(2.0d));

		// arrotonda con un valore minore (più grande) o uguale all'argomento
		System.out.println("1.1d -> " + Math.floor(1.1d));
		System.out.println("1.5d -> " + Math.floor(1.5d));
		System.out.println("1.6d -> " + Math.floor(1.8d));
		System.out.println("2.0d -> " + Math.floor(2.0d));

		// arrotonda con un valore minore (più piccolo) o maggiore (più grande)
		// all'argomento
		System.out.println("1.1d -> " + Math.round(1.1d));
		System.out.println("1.5d -> " + Math.round(1.5d));
		System.out.println("1.6d -> " + Math.round(1.8d));
		System.out.println("2.0d -> " + Math.round(2.0d));
	}
    
    public static void main(String[] args) {
		// Unit test - arrotondamento per difetto
		rounding();       
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: