Project

General

Profile

Bug #8542 ยป bigdecimal-exp-no-mutate-8542.patch

jeremyevans0 (Jeremy Evans), 08/10/2019 05:29 AM

View differences:

ext/bigdecimal/bigdecimal.c
n = prec + rmpd_double_figures();
negative = BIGDECIMAL_NEGATIVE_P(vx);
if (negative) {
VALUE x_zero = INT2NUM(1);
VALUE x_copy = f_BigDecimal(1, &x_zero, klass);
x = BigDecimal_initialize_copy(x_copy, x);
vx = DATA_PTR(x);
VpSetSign(vx, 1);
}
test/bigdecimal/test_bigdecimal.rb
end
end
def test_exp_with_negative
x = BigDecimal(-1)
y = BigMath.exp(x, 20)
assert_equal(y, BigMath.exp(-1, 20))
assert_equal(BigDecimal(-1), x)
end
def test_exp_with_negative_infinite
BigDecimal.save_exception_mode do
BigDecimal.mode(BigDecimal::EXCEPTION_INFINITY, false)
    (1-1/1)