5 Replies - 1365 Views - Last Post: 02 April 2012 - 04:24 PM Rate Topic: -----

#1 JavaBeanie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 29-October 10

Java Math.hypot(a,b) equivalent in C#

Posted 02 April 2012 - 08:30 AM

Hi,

Could someone let me know the C# equivalent to the Java

Math.hypot(a,B)/>


Manyt thanks
Is This A Good Question/Topic? 0
  • +

Replies To: Java Math.hypot(a,b) equivalent in C#

#2 Ryano121  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 1055
  • Posts: 2,234
  • Joined: 30-January 11

Re: Java Math.hypot(a,b) equivalent in C#

Posted 02 April 2012 - 08:41 AM

There is no direct substitute, instead -

System.Math.Sqrt(x * x + y * y);

Was This Post Helpful? 1
  • +
  • -

#3 Sergio Tapia  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 1211
  • View blog
  • Posts: 4,126
  • Joined: 27-January 10

Re: Java Math.hypot(a,b) equivalent in C#

Posted 02 April 2012 - 09:11 AM

Here's a small method I just wrote in a console app:

public static double Hypotenuse(int a, int B)/>
{
    return Math.Sqrt(Math.Pow(a, 2) + Math.Pow(b, 2));
}


There is not direct "Math.Hypt" method in .NET.

This post has been edited by Sergio Tapia: 02 April 2012 - 09:13 AM

Was This Post Helpful? 1
  • +
  • -

#4 superkb10  Icon User is offline

  • D.I.C Regular

Reputation: 25
  • View blog
  • Posts: 272
  • Joined: 27-November 11

Re: Java Math.hypot(a,b) equivalent in C#

Posted 02 April 2012 - 01:20 PM

Hey, just for future reference, if you need to know how to do something in C# that you can do in Java, could you please also say what the function is supposed to do? Because many of us in the C# forum don't know very much Java.
Was This Post Helpful? 0
  • +
  • -

#5 Ryano121  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 1055
  • Posts: 2,234
  • Joined: 30-January 11

Re: Java Math.hypot(a,b) equivalent in C#

Posted 02 April 2012 - 01:25 PM

A very quick Google search however can quickly result in the corresponding Java API documentation page -

Math.hypot
Was This Post Helpful? 0
  • +
  • -

#6 superkb10  Icon User is offline

  • D.I.C Regular

Reputation: 25
  • View blog
  • Posts: 272
  • Joined: 27-November 11

Re: Java Math.hypot(a,b) equivalent in C#

Posted 02 April 2012 - 04:24 PM

Yeah, but some of us are a bit lazy :sleep1:
Was This Post Helpful? -2
  • +
  • -

Page 1 of 1