List of usage examples for java.lang Math sqrt
@HotSpotIntrinsicCandidate public static double sqrt(double a)
From source file:Main.java
public static void main(String[] args) { double d = Math.sqrt(-10); boolean b1 = Double.isNaN(d); System.out.println(b1);/*from ww w. j ava2 s.c o m*/ Double dObj = new Double(d); boolean b2 = dObj.isNaN(); System.out.println(b2); }
From source file:Main.java
public static void main(String[] args) { float f = (float) Math.sqrt(-10); boolean b1 = Float.isNaN(f); System.out.println(b1);/*from www.j a v a2 s.co m*/ Float fObj = new Float(f); boolean b2 = fObj.isNaN(); System.out.println(b2); }
From source file:Main.java
public static void main(String args[]) { // c is dynamically initialized double c = Math.sqrt(2 * 2); System.out.println("c is " + c); }
From source file:Main.java
public static void main(String[] args) { // returns square root of 9, i.e. 3 System.out.println(Math.sqrt(9)); // returns square root of 25.5 System.out.println(Math.sqrt(25.5)); }
From source file:MainClass.java
public static void main(String args[]) { System.out.println(Math.sqrt(10)); }
From source file:MainClass.java
public static void main(String[] args) { // Display the square root of 2 using sqrt() System.out.print("sqrt(2.0) = "); System.out.println(Math.sqrt(2.0)); // Calculate and display using pow() System.out.print("pow(2.0, 0.5) = "); System.out.println(Math.pow(2.0, 0.5)); System.out.println();/* www. j av a2s. c o m*/ }
From source file:Main.java
public static void main(String[] argv) throws Exception { for (double i = 1.0; i < 20.0; i++) System.out.printf("%10.2f %10.2f %10.2f\n", i, Math.sqrt(i), i * i); }
From source file:Main.java
public static void main(String[] args) { double x = 9; double y = 25; // print the square root of these doubles System.out.println("Math.sqrt(" + x + ")=" + Math.sqrt(x)); System.out.println("Math.sqrt(" + y + ")=" + Math.sqrt(y)); }
From source file:TrigSolv.java
public static void main(String[] args) { double a, b, c, angleA, radA; // Apllying Pythagoras' Theorem // Obtain sides from user System.out.println("Side c in terms of sides a and b"); a = 10d;/* w w w . j av a 2 s . c om*/ b = 20d; c = Math.sqrt((a * a) + (b * b)); System.out.println("Side c = " + c); // Using side/angle formula System.out.println("Side c in terms of side b and angle A"); b = 30d; angleA = 20d; radA = Math.toRadians(angleA); c = b * Math.tan(radA); System.out.println("Side c = " + c); }
From source file:Main.java
public static void main(String[] args) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String input = reader.readLine(); double number = Double.parseDouble(input); System.out.println(input + ":" + Math.sqrt(number)); reader.close();//w ww. j a v a 2 s.c om }