Java sqr sqrt(long x)

Here you can find the source of sqrt(long x)

Description

sqrt

License

LGPL

Declaration

public static long sqrt(long x) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {

    public static long sqrt(long x) {
        long y = 0;
        long b = (~Long.MAX_VALUE) >>> 1;
        while (b > 0) {
            if (x >= y + b) {
                x -= y + b;/*from   w  ww . j  a  va  2 s .c om*/
                y >>= 1;
                y += b;
            } else {
                y >>= 1;
            }
            b >>= 2;
        }
        return y;
    }
}

Related

  1. sqrt(float a)
  2. sqrt(float f)
  3. sqrt(int n)
  4. sqrt(int val)
  5. sqrt(long val)
  6. sqrt(Short a)
  7. sqrt(short value)
  8. sqrt2(float x)
  9. sqrt2sq(double x, double y)