static VALUE math_atan2(VALUE obj, VALUE y, VALUE x) { double dx, dy; Need_Float2(y, x); dx = RFLOAT_VALUE(x); dy = RFLOAT_VALUE(y); if (dx == 0.0 && dy == 0.0) domain_error("atan2"); if (isinf(dx) && isinf(dy)) domain_error("atan2"); return DBL2NUM(atan2(dy, dx)); }
static VALUE math_atan2(VALUE obj, VALUE y, VALUE x) { #ifndef M_PI # define M_PI 3.14159265358979323846 #endif double dx, dy; Need_Float2(y, x); dx = RFLOAT_VALUE(x); dy = RFLOAT_VALUE(y); if (dx == 0.0 && dy == 0.0) { if (!signbit(dx)) return DBL2NUM(dy); if (!signbit(dy)) return DBL2NUM(M_PI); return DBL2NUM(-M_PI); } if (isinf(dx) && isinf(dy)) domain_error("atan2"); return DBL2NUM(atan2(dy, dx)); }
static VALUE math_hypot(VALUE obj, VALUE x, VALUE y) { Need_Float2(x, y); return DBL2NUM(hypot(RFLOAT_VALUE(x), RFLOAT_VALUE(y))); }
static VALUE math_atan2(VALUE obj, VALUE y, VALUE x) { Need_Float2(y, x); return DBL2NUM(atan2(RFLOAT_VALUE(y), RFLOAT_VALUE(x))); }