Java Utililty Methods sqr

List of utility methods to do sqr

Description

The list of methods to do sqr are organized into topic(s).

Method

floatsqrt(float a)
sqrt
return (float) StrictMath.sqrt((double) a);
floatsqrt(float f)
sqrt
return (float) Math.sqrt(f);
intsqrt(int n)
sqrt
int s = (n + 65536) >> 1;
for (int i = 0; i < 8; i++) {
    s = (s + div(n, s)) >> 1;
return s;
intsqrt(int val)
sqrt
int temp, g = 0, b = 0x8000, bshft = 15;
do {
    if (val >= (temp = (((g << 1) + b) << bshft--))) {
        g += b;
        val -= temp;
} while ((b >>= 1) > 0);
return g;
...
longsqrt(long val)
sqrt
double epsilon = 1e-15;
double estimate = val;
while (Math.abs(estimate - val / estimate) > epsilon * estimate) {
    estimate = (val / estimate + estimate) / 2l;
return (long) estimate;
longsqrt(long x)
sqrt
long y = 0;
long b = (~Long.MAX_VALUE) >>> 1;
while (b > 0) {
    if (x >= y + b) {
        x -= y + b;
        y >>= 1;
        y += b;
    } else {
...
doublesqrt(Short a)
Sqrt.
return Math.sqrt(a.doubleValue());
shortsqrt(short value)
sqrt
return (short) Math.sqrt(value);
floatsqrt2(float x)
sqrt
x = fastInverseSqrt(x);
if (x > 0) {
    return 1.0f / x;
} else {
    return 0;
doublesqrt2sq(double x, double y)
sqrtsq
return sqrt(sq(x) + sq(y));