edu.rit.util
Class Mathe
- java.lang.Object
-
- edu.rit.util.Mathe
-
public class Mathe extends java.lang.ObjectClass Mathe provides useful mathematical operations. The class is named "Mathe" so the compiler won't confuse it with class java.lang.Math.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static intsqrt(int x)Compute the integer square root of the integer x.
-
-
-
Method Detail
-
sqrt
public static int sqrt(int x)
Compute the integer square root of the integer x. The value floor(x1/2) is returned. The answer is calculated using an exact integer algorithm taken from:- J. Crenshaw. Integer square roots. http://www.embedded.com/98/9802fe2.htm
- Parameters:
x- Input.- Returns:
- Floor(x1/2).
- Throws:
java.lang.ArithmeticException- (unchecked exception) Thrown if x < 0.
-
-
DMelt 3.0 © DataMelt by jWork.ORG