Here you can find the source of sqrt(int val)
public static int sqrt(int val)
//package com.java2s; //License from project: Open Source License public class Main { public static int sqrt(int val) { // using estimate method from http://www.azillionmonkeys.com/qed/sqroot.html // System.out.print(val + ", " + (int)Math.sqrt(val) + ", "); int temp, g = 0, b = 0x8000, bshft = 15; do {// w w w .j av a 2 s. co m if (val >= (temp = (((g << 1) + b) << bshft--))) { g += b; val -= temp; } } while ((b >>= 1) > 0); return g; } }