Skip to content

Commit 4ee140f

Browse files
committed
test: Add 100-digit cases of PI and E
1 parent 62c9f20 commit 4ee140f

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

test/bigdecimal/test_bigmath.rb

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,20 @@ class TestBigMath < Test::Unit::TestCase
1010
MINF = BigDecimal("-Infinity")
1111
NAN = BigDecimal("NaN")
1212

13-
def test_const
14-
assert_in_delta(Math::PI, PI(N))
15-
assert_in_delta(Math::E, E(N))
13+
def test_PI
14+
eps = "1e-#{Float::DIG}".to_f
15+
assert_in_delta(Math::PI, PI(N), eps)
16+
assert_in_delta(BigDecimal("3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068"),
17+
PI(100),
18+
BigDecimal("1e-100"))
19+
end
20+
21+
def test_E
22+
eps = "1e-#{Float::DIG}".to_f
23+
assert_in_delta(Math::E, E(N), eps)
24+
assert_in_delta(BigDecimal("2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427"),
25+
E(100),
26+
BigDecimal("1e-100"))
1627
end
1728

1829
def test_sqrt

0 commit comments

Comments
 (0)