About 2,850,000 results
Open links in new tab
  1. Java sqrt() method with Examples - GeeksforGeeks

    Apr 9, 2018 · The java.lang.Math.sqrt() returns the square root of a value of type double passed to it as argument. If the argument is NaN or negative, then the result is NaN. If the argument is positive infinity, then the result is positive infinity.

  2. Java Math sqrt() Method - W3Schools

    Return the square root of different numbers: Try it Yourself » The sqrt() method returns the square root of a number. Required. A number to find the square root of. A double value representing the square root of a number. If the number is less than 0, it returns NaN.

  3. math - Calculating nth root in Java using power method - Stack Overflow

    Nov 18, 2021 · Use BigDecimal class, which is decimal representation of real numbers with arbitrary precision. Of course there's no method to calculate nth roots in the BigDecimal class. So you'd need to implement it yourself. I'd give the newton raphson method a chance. See here.

  4. java - How do you get absolute values and square roots - Stack Overflow

    Dec 25, 2021 · Use the java.lang.Math class, and specifically for absolute value and square root:, the abs() and sqrt() methods.

  5. Math Class in Java (with Example) - Geekster Article

    The Math class in Java is a built-in class in the java.lang package that provides methods for performing basic mathematical operations like trigonometric functions, logarithms, exponentiation, rounding, and more.

  6. Java Math Class - GeeksforGeeks

    Jul 24, 2024 · Java.lang.Math Class methods help to perform numeric operations like square, square root, cube, cube root, exponential and trigonometric operations. Declaration. extends Object. Math class consists of methods that can perform mathematical operations and can make long calculations a bit easier. Let us check the method provided in the Math class.

  7. Math.sqrt Method - Square Root in Java - CodeGym

    The most common way to find a square root of a number in Java is by applying the java.lang.Math.sqrt() method. Here’s the general syntax of the java.lang.Math.sqrt() method: public static double sqrt(double a) In the method, a is a value elevated to the power of two you want to get square root for. Onc a developer applies java.lang.Math.sqrt ...

  8. How to find the square root and cube root of a number using the …

    Learn how to calculate the square root and cube root of a number in Java using the pow () method. Discover the step-by-step process and explore the versatility of this powerful function.

  9. Java Math: Mathematical Operations and Functions - CodeLucky

    Aug 31, 2024 · Power and Square Root. For exponentiation and square roots: double base = 2; double exponent = 3; double power = Math. pow (base, exponent); // 8.0 double squareRoot = Math. sqrt (16); // 4.0 System.out. println ("2^3: "+ power); System.out. println ("Square root of 16: "+ squareRoot); Trigonometric Functions

  10. Math Class in Java & Methods (with Examples) - FavTutor

    Oct 9, 2023 · The Math class provides a method called sqrt() that returns the square root of a number. You can use this method directly without importing the Math class. Here's an example:

Refresh