diff --git a/math.c b/math.c index a09d605..849d822 100644 --- a/math.c +++ b/math.c @@ -73,23 +73,23 @@ math_atan2(VALUE obj, VALUE y, VALUE x) dx = RFLOAT_VALUE(x); dy = RFLOAT_VALUE(y); if (dx == 0.0 && dy == 0.0) { - if (!signbit(dx)) - return DBL2NUM(dy); + if (!signbit(dx)) + return DBL2NUM(dy); if (!signbit(dy)) - return DBL2NUM(M_PI); - return DBL2NUM(-M_PI); + return DBL2NUM(M_PI); + return DBL2NUM(-M_PI); } #ifndef ATAN2_INF_C99 if (isinf(dx) && isinf(dy)) { - /* optimization for FLONUM */ - if (dx < 0.0) { - const double dz = (3.0 * M_PI / 4.0); - return (dy < 0.0) ? DBL2NUM(-dz) : DBL2NUM(dz); - } - else { - const double dz = (M_PI / 4.0); - return (dy < 0.0) ? DBL2NUM(-dz) : DBL2NUM(dz); - } + /* optimization for FLONUM */ + if (dx < 0.0) { + const double dz = (3.0 * M_PI / 4.0); + return (dy < 0.0) ? DBL2NUM(-dz) : DBL2NUM(dz); + } + else { + const double dz = (M_PI / 4.0); + return (dy < 0.0) ? DBL2NUM(-dz) : DBL2NUM(dz); + } } #endif return DBL2NUM(atan2(dy, dx)); @@ -464,7 +464,7 @@ math_log(int argc, const VALUE *argv, VALUE obj) rb_scan_args(argc, argv, "11", &x, &base); d = math_log1(x); if (argc == 2) { - d /= math_log1(base); + d /= math_log1(base); } return DBL2NUM(d); } @@ -481,7 +481,7 @@ math_log1(VALUE x) x = rb_big_rshift(x, SIZET2NUM(numbits)); } else { - numbits = 0; + numbits = 0; } Need_Float(x); @@ -537,7 +537,7 @@ math_log2(VALUE obj, VALUE x) x = rb_big_rshift(x, SIZET2NUM(numbits)); } else { - numbits = 0; + numbits = 0; } Need_Float(x); @@ -579,7 +579,7 @@ math_log10(VALUE obj, VALUE x) x = rb_big_rshift(x, SIZET2NUM(numbits)); } else { - numbits = 0; + numbits = 0; } Need_Float(x); @@ -854,11 +854,11 @@ math_gamma(VALUE obj, VALUE x) if (isinf(d0) && signbit(d0)) domain_error("gamma"); fracpart = modf(d0, &intpart); if (fracpart == 0.0) { - if (intpart < 0) domain_error("gamma"); - if (0 < intpart && - intpart - 1 < (double)numberof(fact_table)) { - return DBL2NUM(fact_table[(int)intpart - 1]); - } + if (intpart < 0) domain_error("gamma"); + if (0 < intpart && + intpart - 1 < (double)numberof(fact_table)) { + return DBL2NUM(fact_table[(int)intpart - 1]); + } } d = tgamma(d0); return DBL2NUM(d); @@ -888,8 +888,8 @@ math_lgamma(VALUE obj, VALUE x) d0 = RFLOAT_VALUE(x); /* check for domain error */ if (isinf(d0)) { - if (signbit(d0)) domain_error("lgamma"); - return rb_assoc_new(DBL2NUM(INFINITY), INT2FIX(1)); + if (signbit(d0)) domain_error("lgamma"); + return rb_assoc_new(DBL2NUM(INFINITY), INT2FIX(1)); } d = lgamma_r(d0, &sign); v = DBL2NUM(d);