gmp 0.4.7 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/CHANGELOG +31 -0
  2. data/README.rdoc +16 -8
  3. data/benchmark/multiply +1 -1
  4. data/benchmark/multiply.gc +57 -0
  5. data/benchmark/pi +126 -0
  6. data/benchmark/srb.sh +21 -0
  7. data/ext/extconf.rb +3 -0
  8. data/ext/gmp.c +16 -7
  9. data/ext/gmpbench_timing.c +1 -1
  10. data/ext/gmpf.c +445 -104
  11. data/ext/gmpq.c +25 -17
  12. data/ext/gmpz.c +232 -120
  13. data/ext/mprnd.c +23 -5
  14. data/ext/ruby_gmp.h +75 -9
  15. data/lib/gmp.rb +9 -0
  16. data/manual.pdf +0 -0
  17. data/manual.tex +494 -60
  18. data/test/README +1 -0
  19. data/test/mpfr_tcbrt.rb +95 -0
  20. data/test/mpfr_tisnan.rb +70 -0
  21. data/test/mpfr_trec_sqrt.rb +62 -0
  22. data/test/mpfr_tsqrt.rb +142 -6
  23. data/test/tc_cmp.rb +4 -4
  24. data/test/tc_constants.rb +10 -0
  25. data/test/tc_division.rb +13 -2
  26. data/test/tc_f_arithmetics_coersion.rb +2 -2
  27. data/test/tc_f_precision.rb +4 -3
  28. data/test/tc_fib_fac_nextprime.rb +2 -2
  29. data/test/tc_floor_ceil_truncate.rb +2 -2
  30. data/test/tc_hashes.rb +0 -2
  31. data/test/tc_logical_roots.rb +1 -3
  32. data/test/tc_mpfr_constants.rb +11 -0
  33. data/test/tc_mpfr_functions.rb +22 -9
  34. data/test/tc_mpfr_random.rb +1 -3
  35. data/test/tc_mpfr_rounding.rb +10 -7
  36. data/test/tc_q.rb +1 -3
  37. data/test/tc_q_basic.rb +3 -5
  38. data/test/tc_random.rb +1 -3
  39. data/test/tc_sgn_neg_abs.rb +1 -3
  40. data/test/tc_swap.rb +1 -3
  41. data/test/tc_z.rb +3 -3
  42. data/test/tc_z_addmul.rb +92 -0
  43. data/test/tc_z_basic.rb +6 -8
  44. data/test/tc_z_exponentiation.rb +1 -3
  45. data/test/tc_z_gcd_lcm_invert.rb +1 -3
  46. data/test/tc_z_jac_leg_rem.rb +1 -3
  47. data/test/tc_z_logic.rb +2 -2
  48. data/test/tc_z_shifts_last_bits.rb +2 -2
  49. data/test/tc_z_to_d_to_i.rb +2 -2
  50. data/test/test_helper.rb +1 -1
  51. data/test/test_unit/assertions.rb +31 -0
  52. data/test/unit_tests.rb +33 -27
  53. metadata +31 -6
@@ -31,4 +31,5 @@ TODO:
31
31
  more number theoretic functions
32
32
  random numbers
33
33
  range errors
34
+ mpz_size
34
35
  full coverage?
@@ -0,0 +1,95 @@
1
+ require './test_helper'
2
+
3
+ class MPFR_TCBRT < Test::Unit::TestCase
4
+ def setup
5
+ @one = GMP::F(1)
6
+ @zero = GMP::F(0)
7
+ @inf = @one/@zero
8
+ @nan = @inf - @inf
9
+ @neg_one = GMP::F(-1)
10
+ @neg_inf = @neg_one/@zero
11
+ @neg_zero = GMP::F("-0")
12
+ @rand_state = GMP::RandState.new
13
+ end
14
+
15
+ # This really should be moved to be a method of GMP::F
16
+ def integer_component(f)
17
+ index_e = f.to_s.index('e')
18
+ exp = f.to_s[(index_e+1)..-1].to_i
19
+ return 0 if exp < 0
20
+ f.to_s[2..(index_e-1)][0,exp]
21
+ end
22
+
23
+ def special
24
+ x = @nan.cbrt(GMP::GMP_RNDN)
25
+ assert_true(x.nan?, "@nan.cbrt should be NaN")
26
+ x = @inf.cbrt(GMP::GMP_RNDN)
27
+ assert_true(x.infinite?, "@inf.cbrt should be +inf")
28
+ assert_true(x > 0, "@inf.cbrt should be +inf")
29
+ x = @neg_inf.cbrt(GMP::GMP_RNDN)
30
+ assert_true(x.infinite?, "@neg_inf.cbrt should be -inf")
31
+ assert_true(x < 0, "@neg_inf.cbrt should be -inf")
32
+ x = @zero.cbrt(GMP::GMP_RNDN)
33
+ assert_true(x.zero?, "@zero.cbrt should be +0")
34
+ assert_equal(GMP::F(0), x, "@zero.cbrt should be +0")
35
+ x = @neg_zero.cbrt(GMP::GMP_RNDN)
36
+ assert_true(x.zero?, "@neg_zero.cbrt should be -0")
37
+ assert_equal(GMP::F("-0"), x, "@neg_zero.cbrt should be -0")
38
+
39
+ x = GMP::F("8.39005285514734966412e-01", 53)
40
+ x = x.cbrt(GMP::GMP_RNDN)
41
+ y = GMP::F("9.43166207799662426048e-01")
42
+ assert_equal(y, x, "cbrt should be correct")
43
+
44
+ x = GMP::F("0.10000100001100101001001001011001", 32, 2)
45
+ x = x.cbrt(GMP::GMP_RNDN)
46
+ y = GMP::F("0.11001101011000100111000111111001", 32, 2)
47
+ assert_equal(y, x, "cbrt should be correct")
48
+
49
+ x = GMP::F("-0.1100001110110000010101011001011", 32, 2)
50
+ x = x.cbrt(GMP::GMP_RNDD)
51
+ y = GMP::F("-0.11101010000100100101000101011001", 32, 2)
52
+ assert_equal(y, x, "cbrt should be correct")
53
+
54
+ x = GMP::F("0.1010001111011101011011000111001011001101100011110110010011011011011010011001100101e-7", 82, 2)
55
+ y = x.cbrt(GMP::GMP_RNDD, 27)
56
+ x = GMP::F("0.101011110001110001000100011E-2", 82, 2)
57
+ assert_equal(x, y, "cbrt should be correct")
58
+
59
+ x = GMP::F("0.1010000000011010000000011001111110111110011101101000011110" +
60
+ "0010011010011100110110011111000111000101101101011001001110" +
61
+ "0101111001111100001010010100111011101100000011011000101100" +
62
+ "010000000011000101001010001001E-5", 204, 2)
63
+ y = x.cbrt(GMP::GMP_RNDD, 38)
64
+ x = GMP::F("0.10001001111010011011101000010110110010E-1", 204, 2)
65
+ assert_equal(x, y, "cbrt should be correct")
66
+
67
+ x = GMP::F("1.1000E-2", 5, 2)
68
+ x = x.cbrt(GMP::GMP_RNDN)
69
+ y = GMP::F("1.0111E-1", 5, 2)
70
+ assert_equal(y, x, "cbrt should be correct")
71
+ end
72
+
73
+ def test_cbrt
74
+ special
75
+
76
+ (2..100).each do |p|
77
+ [GMP::GMP_RNDN, GMP::GMP_RNDZ, GMP::GMP_RNDD, GMP::GMP_RNDU].each do |rnd|
78
+ x = GMP::F(1).cbrt(rnd)
79
+ assert_equal(GMP::F(1), x, "1.cbrt should be 1 (prec #{p}) in rounding mode #{rnd}")
80
+ x = GMP::F(-1).cbrt(rnd)
81
+ assert_equal(GMP::F(-1), x, "-1.cbrt should be -1 (prec #{p}) in rounding mode #{rnd}")
82
+
83
+ next unless p>=5
84
+
85
+ (-12..12).each do |i|
86
+ x = GMP::F(27)
87
+ x *= GMP::F(2)**(3*i)
88
+ x = x.cbrt
89
+ assert_equal(GMP::F(3)*GMP::F(2)**i, x,
90
+ "27*2^#{3*i} should be 3*2^#{i} (prec #{p}, rounding mode #{rnd}")
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,70 @@
1
+ require './test_helper'
2
+
3
+ class MPFR_ISNAN < Test::Unit::TestCase
4
+ def setup
5
+ @rand_state = GMP::RandState.new
6
+ @one = GMP::F(1)
7
+ @zero = GMP::F(0)
8
+ @inf = @one/@zero
9
+ @neg_one = GMP::F(-1)
10
+ @neg_inf = @neg_one/@zero
11
+ @nan = @neg_inf - @neg_inf
12
+ @neg_zero = GMP::F("-0")
13
+ end
14
+
15
+ def test_nan
16
+ assert_false(@inf.nan?, "@inf.nan? should be false")
17
+ assert_false(@neg_inf.nan?, "@neg_inf.nan? should be false")
18
+ assert_true(@nan.nan?, "@nan.nan? should be true")
19
+ assert_false(@one.nan?, "@one.nan? should be false")
20
+ assert_false(@zero.nan?, "@zero.nan? should be false")
21
+ assert_false(@neg_zero.nan?, "@neg_zero.nan? should be false")
22
+ end
23
+
24
+ def test_infinite
25
+ assert_true(@inf.infinite?, "@inf.infinite? should be true")
26
+ assert_true(@neg_inf.infinite?, "@neg_inf.infinite? should be true")
27
+ assert_false(@nan.infinite?, "@nan.infinite? should be false")
28
+ assert_false(@one.infinite?, "@one.infinite? should be false")
29
+ assert_false(@zero.infinite?, "@zero.infinite? should be false")
30
+ assert_false(@neg_zero.infinite?, "@neg_zero.infinite? should be false")
31
+ end
32
+
33
+ def test_finite
34
+ assert_false(@inf.finite?, "@inf.finite? should be false")
35
+ assert_false(@neg_inf.finite?, "@neg_inf.finite? should be false")
36
+ #assert_true(@nan.finite?, "@nan.finite? should be true") // eh...
37
+ assert_true(@one.finite?, "@one.finite? should be true")
38
+ assert_true(@zero.finite?, "@zero.finite? should be true")
39
+ assert_true(@neg_zero.finite?, "@neg_zero.finite? should be true")
40
+ end
41
+
42
+ def test_number
43
+ assert_false(@inf.number?, "@inf.number? should be false")
44
+ assert_false(@neg_inf.number?, "@neg_inf.number? should be false")
45
+ assert_false(@nan.number?, "@nan.number? should be false")
46
+ assert_true(@one.number?, "@one.number? should be true")
47
+ assert_true(@zero.number?, "@zero.number? should be true")
48
+ assert_true(@neg_zero.number?, "@neg_zero.number? should be true")
49
+ end
50
+
51
+ def test_zero
52
+ assert_false(@inf.zero?, "@inf.zero? should be false")
53
+ assert_false(@neg_inf.zero?, "@neg_inf.zero? should be false")
54
+ assert_false(@nan.zero?, "@nan.zero? should be false")
55
+ assert_false(@one.zero?, "@one.zero? should be false")
56
+ assert_true(@zero.zero?, "@zero.zero? should be true")
57
+ assert_true(@neg_zero.zero?, "@neg_zero.zero? should be true")
58
+ end
59
+
60
+ def test_regular
61
+ if GMP::MPFR_VERSION >= "3.0.0"
62
+ assert_false(@inf.regular?, "@inf.regular? should be false")
63
+ assert_false(@neg_inf.regular?, "@neg_inf.regular? should be false")
64
+ assert_false(@nan.regular?, "@nan.regular? should be false")
65
+ assert_true(@one.regular?, "@one.regular? should be true")
66
+ assert_false(@zero.regular?, "@zero.regular? should be false")
67
+ assert_false(@neg_zero.regular?, "@neg_zero.regular? should be false")
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,62 @@
1
+ require './test_helper'
2
+
3
+ class MPFR_TREC_SQRT < Test::Unit::TestCase
4
+ def setup
5
+ @rand_state = GMP::RandState.new
6
+ @one = GMP::F(1)
7
+ @zero = GMP::F(0)
8
+ @inf = @one/@zero
9
+ @nan = @inf - @inf
10
+ @neg_zero = GMP::F("-0")
11
+ @neg_one = GMP::F(-1)
12
+ @neg_inf = @neg_one/@zero
13
+ end
14
+
15
+ # This really should be moved to be a method of GMP::F
16
+ def integer_component(f)
17
+ index_e = f.to_s.index('e')
18
+ exp = f.to_s[(index_e+1)..-1].to_i
19
+ return 0 if exp < 0
20
+ f.to_s[2..(index_e-1)][0,exp]
21
+ end
22
+
23
+ def special
24
+ x = @nan.rec_sqrt(GMP::GMP_RNDN)
25
+ assert_true(x.nan?, "@nan.rec_sqrt should be NaN")
26
+ x = @inf.rec_sqrt(GMP::GMP_RNDN)
27
+ assert_true(x.zero?, "@inf.rec_sqrt should be +0")
28
+ assert_true(x.hash != @neg_zero.hash, "@inf.rec_sqrt should be +0")
29
+ x = @neg_inf.rec_sqrt(GMP::GMP_RNDN)
30
+ assert_true(x.nan?, "@neg_inf.rec_sqrt should be NaN")
31
+ x = @zero.rec_sqrt(GMP::GMP_RNDN)
32
+ assert_true(x.infinite?, "@zero.rec_sqrt should be inf")
33
+ x = @neg_zero.rec_sqrt(GMP::GMP_RNDN)
34
+ assert_true(x.infinite?, "@neg_zero.rec_sqrt should be inf")
35
+ x = @neg_one.rec_sqrt(GMP::GMP_RNDN)
36
+ assert_true(x.nan?, "@neg_one.rec_sqrt should be NaN")
37
+ x = @one.rec_sqrt(GMP::GMP_RNDN)
38
+ assert_equal(@one, x, "@one.rec_sqrt should be 1")
39
+
40
+ # Can't do 0b1e-1 yet
41
+ #x = GMP::F("0b1.0001110110101001010100e-1", 23)
42
+ #y = x.rec_sqrt(GMP::GMP_RNDU, 33)
43
+ #x = GMP::F("0b1.01010110101110100100100101011", 33)
44
+ #assert_equal(x, y, "something about precision...")
45
+ end
46
+
47
+ def bad_case1
48
+ x = GMP::F("1.08310518720928b30e@-120", 72, 16, GMP::GMP_RNDN)
49
+ z = GMP::F("f.8@59", 6, 16, GMP::GMP_RNDN)
50
+ # z = rec_sqrt(x) rounded on 6 bits toward 0, the exact value being
51
+ # ~= f.bffffffffffffffffa11@59
52
+ y = x.rec_sqrt(GMP::GMP_RNDZ, 6)
53
+ assert_equal(y, z, "These should be equal...")
54
+ end
55
+
56
+ def test_prec
57
+ special
58
+ bad_case1
59
+ #generic
60
+ #bad_cases
61
+ end
62
+ end
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require './test_helper'
2
2
 
3
3
  class MPFR_TSQRT < Test::Unit::TestCase
4
4
  def setup
@@ -13,12 +13,64 @@ class MPFR_TSQRT < Test::Unit::TestCase
13
13
  f.to_s[2..(index_e-1)][0,exp]
14
14
  end
15
15
 
16
+ def check24(as, rnd_mode, qs)
17
+ q = GMP::F(as, 24)
18
+ q = q.sqrt(rnd_mode)
19
+ assert_equal(q, GMP::F(qs), "Sqrt of #{as} (prec 24) should be #{qs}.")
20
+ end
21
+
16
22
  def check_diverse(as, p, qs)
17
23
  q = GMP::F(as, p)
18
24
  q = q.sqrt
19
25
  assert_equal(integer_component(q), qs)
20
26
  end
21
27
 
28
+ def check_float
29
+ check24("70368760954880.0", GMP::GMP_RNDN, "8.388609e6")
30
+ check24("281474943156224.0", GMP::GMP_RNDN, "1.6777215e7")
31
+ check24("70368777732096.0", GMP::GMP_RNDN, "8.388610e6")
32
+ check24("281474909601792.0", GMP::GMP_RNDN, "1.6777214e7")
33
+ check24("100216216748032.0", GMP::GMP_RNDN, "1.0010805e7")
34
+ check24("120137273311232.0", GMP::GMP_RNDN, "1.0960715e7")
35
+ check24("229674600890368.0", GMP::GMP_RNDN, "1.5155019e7")
36
+ check24("70368794509312.0", GMP::GMP_RNDN, "8.388611e6")
37
+ check24("281474876047360.0", GMP::GMP_RNDN, "1.6777213e7")
38
+ check24("91214552498176.0", GMP::GMP_RNDN, "9.550631e6")
39
+
40
+ check24("70368760954880.0", GMP::GMP_RNDZ, "8.388608e6")
41
+ check24("281474943156224.0", GMP::GMP_RNDZ, "1.6777214e7")
42
+ check24("70368777732096.0", GMP::GMP_RNDZ, "8.388609e6")
43
+ check24("281474909601792.0", GMP::GMP_RNDZ, "1.6777213e7")
44
+ check24("100216216748032.0", GMP::GMP_RNDZ, "1.0010805e7")
45
+ check24("120137273311232.0", GMP::GMP_RNDZ, "1.0960715e7")
46
+ check24("229674600890368.0", GMP::GMP_RNDZ, "1.5155019e7")
47
+ check24("70368794509312.0", GMP::GMP_RNDZ, "8.38861e6")
48
+ check24("281474876047360.0", GMP::GMP_RNDZ, "1.6777212e7")
49
+ check24("91214552498176.0", GMP::GMP_RNDZ, "9.550631e6")
50
+
51
+ check24("70368760954880.0", GMP::GMP_RNDU, "8.388609e6")
52
+ check24("281474943156224.0", GMP::GMP_RNDU, "1.6777215e7")
53
+ check24("70368777732096.0", GMP::GMP_RNDU, "8.388610e6")
54
+ check24("281474909601792.0", GMP::GMP_RNDU, "1.6777214e7")
55
+ check24("100216216748032.0", GMP::GMP_RNDU, "1.0010806e7")
56
+ check24("120137273311232.0", GMP::GMP_RNDU, "1.0960716e7")
57
+ check24("229674600890368.0", GMP::GMP_RNDU, "1.515502e7")
58
+ check24("70368794509312.0", GMP::GMP_RNDU, "8.388611e6")
59
+ check24("281474876047360.0", GMP::GMP_RNDU, "1.6777213e7")
60
+ check24("91214552498176.0", GMP::GMP_RNDU, "9.550632e6")
61
+
62
+ check24("70368760954880.0", GMP::GMP_RNDD, "8.388608e6")
63
+ check24("281474943156224.0", GMP::GMP_RNDD, "1.6777214e7")
64
+ check24("70368777732096.0", GMP::GMP_RNDD, "8.388609e6")
65
+ check24("281474909601792.0", GMP::GMP_RNDD, "1.6777213e7")
66
+ check24("100216216748032.0", GMP::GMP_RNDD, "1.0010805e7")
67
+ check24("120137273311232.0", GMP::GMP_RNDD, "1.0960715e7")
68
+ check24("229674600890368.0", GMP::GMP_RNDD, "1.5155019e7")
69
+ check24("70368794509312.0", GMP::GMP_RNDD, "8.38861e6")
70
+ check24("281474876047360.0", GMP::GMP_RNDD, "1.6777212e7")
71
+ check24("91214552498176.0", GMP::GMP_RNDD, "9.550631e6")
72
+ end
73
+
22
74
  def special
23
75
  x = GMP::F(0b1010000010100011011001010101010010001100001101011101110001011001 / 2, 64) # Ruby 0b does not support e,
24
76
  y = x.sqrt(GMP::GMP_RNDN, 32) # ie 0b11e-2 = 0.75 doesnt work
@@ -47,12 +99,17 @@ class MPFR_TSQRT < Test::Unit::TestCase
47
99
  z = GMP::F(-1)
48
100
  z = x.sqrt(GMP::GMP_RNDN)
49
101
 
50
- # z = GMP::F(0.1011010100000100100100100110011001011100100100000011000111011001011101101101110000110100001000100001100001011000E1, 160)
51
- # x = z.sqrt
102
+ #z = GMP::F(0.1011010100000100100100100110011001011100100100000011000111011001011101101101110000110100001000100001100001011000E1, 160)
103
+ #x = z.sqrt
52
104
  # z = x.sqrt
53
105
  # x.prec = 53
54
106
  end
55
107
 
108
+ def check_inexact(prec)
109
+ x = @rand_state.mpfr_urandomb(p)
110
+
111
+ end
112
+
56
113
  def property1(p, rounding)
57
114
  x = @rand_state.mpfr_urandomb(p)
58
115
  y = @rand_state.mpfr_urandomb(p)
@@ -63,8 +120,20 @@ class MPFR_TSQRT < Test::Unit::TestCase
63
120
 
64
121
  def property2(p, rounding)
65
122
  x = @rand_state.mpfr_urandomb(p)
66
- y = (x ** 2).sqrt(rounding)
67
- assert_true(x == y, "sqrt(x^2) = x should hold.")
123
+ y = (x * x).sqrt(rounding)
124
+ assert_true(x == y, "sqrt(#{x.to_s}^2) should be #{x.to_s}, but is #{y.to_s} (rounding: #{GMP::F.default_rounding_mode.inspect}, prec: #{p.to_s}).")
125
+ end
126
+
127
+ def check3(as, rounding, qs)
128
+ q = GMP::F(as, 53)
129
+ q = q.sqrt(rounding)
130
+ assert_equal(GMP::F(qs), q, "Sqrt of -0.0 should be something like 0.0.")
131
+ end
132
+
133
+ def check4(as, rounding, qs)
134
+ q = GMP::F(as, 53)
135
+ q = q.sqrt(rounding)
136
+ assert_equal(q, GMP::F(qs, GMP::F.default_prec, 16), "Sqrt of #{as} should be #{qs}.")
68
137
  end
69
138
 
70
139
  def test_prec
@@ -78,5 +147,72 @@ class MPFR_TSQRT < Test::Unit::TestCase
78
147
  160,
79
148
  "796887792767063979679855997149887366668464780637")
80
149
  special
150
+ #check_nan
151
+
152
+ (2...200).each do |p|
153
+ 200.times do
154
+ #check_inexact p
155
+ end
156
+ end
157
+ check_float
158
+
159
+ check3("-0.0", GMP::GMP_RNDN, "0.0")
160
+
161
+ check4("6.37983013646045901440e+32", GMP::GMP_RNDN, "5.9bc5036d09e0c@13")
162
+ check4("1.0", GMP::GMP_RNDN, "1")
163
+ check4("1.0", GMP::GMP_RNDZ, "1")
164
+ check4("3.725290298461914062500000e-9", GMP::GMP_RNDN, "4@-4")
165
+ check4("3.725290298461914062500000e-9", GMP::GMP_RNDZ, "4@-4")
166
+
167
+ check4("1190456976439861.0", GMP::GMP_RNDZ, "2.0e7957873529a@6")
168
+ check4("1219027943874417664.0", GMP::GMP_RNDZ, "4.1cf2af0e6a534@7")
169
+ # the following examples are bugs in Cygnus compiler/system, found by
170
+ # Fabrice Rouillier while porting mpfr to Windows
171
+ check4("9.89438396044940256501e-134", GMP::GMP_RNDU, "8.7af7bf0ebbee@-56")
172
+ check4("7.86528588050363751914e+31", GMP::GMP_RNDZ, "1.f81fc40f32062@13")
173
+ check4("0.99999999999999988897", GMP::GMP_RNDN, "f.ffffffffffff8@-1")
174
+ check4("1.00000000000000022204", GMP::GMP_RNDN, "1")
175
+ # the following examples come from the paper "Number-theoretic Test
176
+ # Generation for Directed Rounding" from Michael Parks, Table 4
177
+ check4("78652858805036375191418371571712.0", GMP::GMP_RNDN, "1.f81fc40f32063@13")
178
+ check4("38510074998589467860312736661504.0", GMP::GMP_RNDN, "1.60c012a92fc65@13")
179
+ check4("35318779685413012908190921129984.0", GMP::GMP_RNDN, "1.51d17526c7161@13")
180
+ check4("26729022595358440976973142425600.0", GMP::GMP_RNDN, "1.25e19302f7e51@13")
181
+ check4("22696567866564242819241453027328.0", GMP::GMP_RNDN, "1.0ecea7dd2ec3d@13")
182
+ check4("22696888073761729132924856434688.0", GMP::GMP_RNDN, "1.0ecf250e8e921@13")
183
+ check4("36055652513981905145251657416704.0", GMP::GMP_RNDN, "1.5552f3eedcf33@13")
184
+ check4("30189856268896404997497182748672.0", GMP::GMP_RNDN, "1.3853ee10c9c99@13")
185
+ check4("36075288240584711210898775080960.0", GMP::GMP_RNDN, "1.556abe212b56f@13")
186
+ check4("72154663483843080704304789585920.0", GMP::GMP_RNDN, "1.e2d9a51977e6e@13")
187
+ check4("78652858805036375191418371571712.0", GMP::GMP_RNDZ, "1.f81fc40f32062@13")
188
+ check4("38510074998589467860312736661504.0", GMP::GMP_RNDZ, "1.60c012a92fc64@13")
189
+ check4("35318779685413012908190921129984.0", GMP::GMP_RNDZ, "1.51d17526c716@13")
190
+ check4("26729022595358440976973142425600.0", GMP::GMP_RNDZ, "1.25e19302f7e5@13")
191
+ check4("22696567866564242819241453027328.0", GMP::GMP_RNDZ, "1.0ecea7dd2ec3c@13")
192
+ check4("22696888073761729132924856434688.0", GMP::GMP_RNDZ, "1.0ecf250e8e92@13")
193
+ check4("36055652513981905145251657416704.0", GMP::GMP_RNDZ, "1.5552f3eedcf32@13")
194
+ check4("30189856268896404997497182748672.0", GMP::GMP_RNDZ, "1.3853ee10c9c98@13")
195
+ check4("36075288240584711210898775080960.0", GMP::GMP_RNDZ, "1.556abe212b56e@13")
196
+ check4("72154663483843080704304789585920.0", GMP::GMP_RNDZ, "1.e2d9a51977e6d@13")
197
+ check4("78652858805036375191418371571712.0", GMP::GMP_RNDU, "1.f81fc40f32063@13")
198
+ check4("38510074998589467860312736661504.0", GMP::GMP_RNDU, "1.60c012a92fc65@13")
199
+ check4("35318779685413012908190921129984.0", GMP::GMP_RNDU, "1.51d17526c7161@13")
200
+ check4("26729022595358440976973142425600.0", GMP::GMP_RNDU, "1.25e19302f7e51@13")
201
+ check4("22696567866564242819241453027328.0", GMP::GMP_RNDU, "1.0ecea7dd2ec3d@13")
202
+ check4("22696888073761729132924856434688.0", GMP::GMP_RNDU, "1.0ecf250e8e921@13")
203
+ check4("36055652513981905145251657416704.0", GMP::GMP_RNDU, "1.5552f3eedcf33@13")
204
+ check4("30189856268896404997497182748672.0", GMP::GMP_RNDU, "1.3853ee10c9c99@13")
205
+ check4("36075288240584711210898775080960.0", GMP::GMP_RNDU, "1.556abe212b56f@13")
206
+ check4("72154663483843080704304789585920.0", GMP::GMP_RNDU, "1.e2d9a51977e6e@13")
207
+ check4("78652858805036375191418371571712.0", GMP::GMP_RNDD, "1.f81fc40f32062@13")
208
+ check4("38510074998589467860312736661504.0", GMP::GMP_RNDD, "1.60c012a92fc64@13")
209
+ check4("35318779685413012908190921129984.0", GMP::GMP_RNDD, "1.51d17526c716@13")
210
+ check4("26729022595358440976973142425600.0", GMP::GMP_RNDD, "1.25e19302f7e5@13")
211
+ check4("22696567866564242819241453027328.0", GMP::GMP_RNDD, "1.0ecea7dd2ec3c@13")
212
+ check4("22696888073761729132924856434688.0", GMP::GMP_RNDD, "1.0ecf250e8e92@13")
213
+ check4("36055652513981905145251657416704.0", GMP::GMP_RNDD, "1.5552f3eedcf32@13")
214
+ check4("30189856268896404997497182748672.0", GMP::GMP_RNDD, "1.3853ee10c9c98@13")
215
+ check4("36075288240584711210898775080960.0", GMP::GMP_RNDD, "1.556abe212b56e@13")
216
+ check4("72154663483843080704304789585920.0", GMP::GMP_RNDD, "1.e2d9a51977e6d@13")
81
217
  end
82
- end
218
+ end
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require './test_helper'
2
2
 
3
3
  class TC_Cmp < Test::Unit::TestCase
4
4
  def setup
@@ -61,7 +61,7 @@ class TC_Cmp < Test::Unit::TestCase
61
61
  def test_cmp_z_int
62
62
  assert_equal(@a <=> @e, -1, "GMP::Z should <=> correctly with Fixnum")
63
63
  assert_equal(@e <=> @a, 1, "Fixnum should <=> correctly with GMP::Z")
64
- assert_equal(@a <=> @f, -1, "GMP::Z should <=> correctly with Bignum")
64
+ assert_equal(-1, @a <=> @f, "GMP::Z should <=> correctly with Bignum")
65
65
  assert_equal(@f <=> @a, 1, "Bignum should <=> correctly with GMP::Z")
66
66
  end
67
67
 
@@ -69,6 +69,6 @@ class TC_Cmp < Test::Unit::TestCase
69
69
  assert_equal(@c <=> @e, -1, "GMP::Q should <=> correctly with Fixnum")
70
70
  assert_equal(@e <=> @c, 1, "Fixnum should <=> correctly with GMP::Q")
71
71
  assert_equal(@c <=> @f, -1, "GMP::Q should <=> correctly with Bignum")
72
- assert_equal(@f <=> @c, 1, "Bignum should <=> correctly with GMP::Q")
72
+ assert_equal(1, @f <=> @c, "Bignum should <=> correctly with GMP::Q")
73
73
  end
74
- end
74
+ end
@@ -0,0 +1,10 @@
1
+ require './test_helper'
2
+
3
+ class TC_Constants < Test::Unit::TestCase
4
+ def test_constants
5
+ assert_instance_of(String, GMP::GMP_VERSION, "GMP::GMP_VERSION should be a String")
6
+ assert_instance_of(String, GMP::GMP_CC, "GMP::GMP_CC should be a String")
7
+ assert_instance_of(String, GMP::GMP_CFLAGS, "GMP::GMP_CFLAGS should be a String")
8
+ assert_instance_of(Fixnum, GMP::GMP_BITS_PER_LIMB, "GMP::GMP_BITS_PER_LIMB should be a Fixnum")
9
+ end
10
+ end