Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,943 questions

51,883 answers

573 users

How to use the hypot() to get the square root of the sum of squares of its arguments in Java

1 Answer

0 votes
package javaapplication1;

public class JavaApplication1 {
 
    public static void main(String[] args) {
        
        System.out.println("Math.hypot(3, 4) = " + Math.hypot(3, 4));
        System.out.println("Math.sqrt(3*3 + 4*4) = " + Math.sqrt(3*3 + 4*4));
        System.out.println("Math.hypot(1, 1) = " + Math.hypot(1, 1));
        System.out.println("Math.hypot(-9, -25) = " + Math.hypot(-9, -25));
        System.out.println("Math.hypot('3', '4') = " + Math.hypot('3', '4'));
    }
}
 
/*
run:

Math.hypot(3, 4) = 5.0
Math.sqrt(3*3 + 4*4) = 5.0
Math.hypot(1, 1) = 1.4142135623730951
Math.hypot(-9, -25) = 26.570660511172846
Math.hypot('3', '4') = 72.83543093852057
 
*/

 



answered Sep 10, 2016 by avibootz
edited Oct 17, 2017 by avibootz
...