static public Method

Math.hypot(p1, p2)

Math.hypot(x, y)     float

Returns sqrt(x**2 + y**2), the hypotenuse of a right-angled triangle with sides x and y.

Math.hypot(3, 4)   #=> 5.0

Source Code

/*
*  call-seq:
*     Math.hypot(x, y)    => float
*  
*  Returns sqrt(x**2 + y**2), the hypotenuse of a right-angled triangle
*  with sides <i>x</i> and <i>y</i>.
*     
*     Math.hypot(3, 4)   #=> 5.0
*/

static VALUE
math_hypot(obj, x, y)
   VALUE obj, x, y;
{
   Need_Float2(x, y);
   return rb_float_new(hypot(RFLOAT(x)->value, RFLOAT(y)->value));
}
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.