Converted Math.cpp to ExtendedMath.java.