package javaapplication1;
public class JavaApplication1 {
public static void main(String[] args) {
try {
double d1 = 3.1415;
double d2 = -2.789;
System.out.println(Math.floor(d1));
System.out.println(Math.floor(d2));
System.out.println(Math.round(d1));
System.out.println(Math.round(d2));
// Casting to int will remove the fractional part
// Truncate the number
System.out.println((int) d1);
System.out.println((int) d2);
} catch (Exception e) {
System.out.println(e.toString());
}
}
}
/*
run:
3.0
-3.0
3
-3
3
-2
*/