package org.example.math; import com.google.common.math.*; import java.math.BigInteger; import java.math.RoundingMode; import static java.math.RoundingMode.CEILING; import static java.math.RoundingMode.FLOOR; public class MathGuava { public static void main(String[] args) { int logFloor = LongMath.log2(3, FLOOR); int mustNotOverflow = IntMath.checkedMultiply(121, 8746); long quotient = LongMath.divide(18, 3, RoundingMode.UNNECESSARY); // fail fast on non-multiple of 3 BigInteger nearestInteger = DoubleMath.roundToBigInteger(348.33, RoundingMode.HALF_EVEN); BigInteger sideLength = BigIntegerMath.sqrt(new BigInteger(String.valueOf(144)), CEILING); System.out.println(logFloor); System.out.println(mustNotOverflow); System.out.println(quotient); System.out.println(nearestInteger); System.out.println(sideLength); } }