Project

General

Profile

Feature #9799 ยป f36b9cd63c8218d17a4ddf346a88b9d64a62f557.diff

cremno (cremno phobia), 05/03/2014 02:45 AM

View differences:

math.c
return DBL2NUM(M_PI);
return DBL2NUM(-M_PI);
}
if (isinf(dx) && isinf(dy)) domain_error("atan2");
if (isinf(dx) && isinf(dy)) {
double dz = (dx < 0.0) ? (3.0 * M_PI / 4.0) : (M_PI / 4.0);
if (dy < 0.0) dz = -dz;
return DBL2NUM(dz);
}
return DBL2NUM(atan2(dy, dx));
}
test/ruby/test_math.rb
check(-0.0, Math.atan2(-0.0, +0.0))
check(+Math::PI, Math.atan2(+0.0, -0.0))
check(-Math::PI, Math.atan2(-0.0, -0.0))
assert_raise(Math::DomainError) { Math.atan2(Float::INFINITY, Float::INFINITY) }
assert_raise(Math::DomainError) { Math.atan2(Float::INFINITY, -Float::INFINITY) }
assert_raise(Math::DomainError) { Math.atan2(-Float::INFINITY, Float::INFINITY) }
assert_raise(Math::DomainError) { Math.atan2(-Float::INFINITY, -Float::INFINITY) }
inf = Float::INFINITY
expected = 3.0 * Math::PI / 4.0
assert_nothing_raised { check(+expected, Math.atan2(+inf, -inf)) }
assert_nothing_raised { check(-expected, Math.atan2(-inf, -inf)) }
expected = Math::PI / 4.0
assert_nothing_raised { check(+expected, Math.atan2(+inf, +inf)) }
assert_nothing_raised { check(-expected, Math.atan2(-inf, +inf)) }
check(0, Math.atan2(0, 1))
check(Math::PI / 4, Math.atan2(1, 1))
check(Math::PI / 2, Math.atan2(1, 0))
    (1-1/1)