package expressions;

public class MoreMathExpressions {
    public static void main(String[] args) {

        /*
         * More interesting operations can be performed with the
         * help of the Math class.
         * https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/Math.html
         */

        // exponents and roots
        System.out.println("exponents and roots");
        int x = 5;
        int y = 2;
        double power = Math.pow(x, y);
        System.out.println(power);
        double root = Math.sqrt(81);
        System.out.println(root);
        double cubedRoot = Math.cbrt(64);
        System.out.println(cubedRoot);

        // rounding etc.
        System.out.println("rounding etc");
        double a = 1.7;
        double b = -2.3;
        System.out.println(Math.abs(a));
        System.out.println(Math.abs(b));
        System.out.println(Math.ceil(a));
        System.out.println(Math.ceil(b));
        System.out.println(Math.floor(a));
        System.out.println(Math.floor(b));
        System.out.println(Math.round(a));
        System.out.println(Math.round(b));

        // other
        System.out.println("other");
        System.out.println(Math.max(a, b));
        System.out.println(Math.min(a, b));
        a = 8;
        b = 6;
        double c = Math.hypot(a, b);
        System.out.println(c);
    }
}
