gmp 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,17 @@
1
+ 0.18:
2
+ * Added test: tc_division, in progress.
3
+ * Unit test results: 56 tests, 361 assertions, 0 failures, 0 errors
4
+ * Added to_f ==> to_d aliases for GMP::Q and GMP::F.
5
+
6
+ 0.1.7:
7
+ * Added tests: tc_shifts_last_bits, tc_logical_roots, tc_f_precision,
8
+ tc_f_arithmetics_coersion, tc_default_prec
9
+ * Unit test results: 54 tests, 326 assertions, 0 failures, 0 errors
10
+ * Fixed defect in GMP::F.sub when argument is Bignum
11
+ * Fixed defect in GMP::F.div when argument is Bignum
12
+ * Added documentation "manual" in form of a LaTeX-based PDF. Very incomplete
13
+ * as of yet.
14
+
1
15
  0.1.6.2:
2
16
  * Added optional argument to GMP::Z.to_s. Supply base as either a Fixnum or
3
17
  a Symbol like :hex to get the string in a different base.
@@ -241,11 +241,11 @@ still relevant.
241
241
  * better bignum parser
242
242
  * zero-copy method for strings generation
243
243
  * put rb_raise into nice macros
244
- * benchmarks against Python GMP and Perl GMP
244
+ * benchmarks against Python GMP (gmpy? Is this still active?) and Perl GMP (I can't
245
+ find this either!)
245
246
  * dup methods
246
247
  * integrate F into system
247
248
  * should Z.[] bits be 0/1 or true/false, 0 is true, what might badly surprise users
248
- * seriously investigate Ruby Makefile-making system
249
249
  * any2small_integer()
250
250
  * check asm output, especially local memory efficiency
251
251
  * it might be better to use `register' for some local variables
data/ext/gmpq.c CHANGED
@@ -743,6 +743,7 @@ void init_gmpq()
743
743
 
744
744
  // Rational Conversions
745
745
  rb_define_method(cGMP_Q, "to_d", r_gmpq_to_d, 0);
746
+ rb_define_alias(cGMP_Q, "to_f", "to_d");
746
747
  rb_define_method(cGMP_Q, "to_s", r_gmpq_to_s, 0);
747
748
 
748
749
  // Rational Arithmetic
data/manual.tex CHANGED
@@ -169,7 +169,9 @@ In addition to the above three classes, there is also one constant within \textt
169
169
 
170
170
  \large{\textbf{GMP::Z.new(a = 0)}}\\
171
171
  \large{\textbf{GMP::Z(a = 0)}}\\
172
- This method creates a new \texttt{GMP::Z} integer. It takes one optional argument for the value of the integer. This argument can be one of several classes. Here are some examples:
172
+ This method creates a new \texttt{GMP::Z} integer. It takes one optional argument for the
173
+ value of the integer. This argument can be one of several classes. Here are some
174
+ examples:
173
175
  \begin{verbatim}
174
176
  GMP::Z.new #=> 0 (default)
175
177
  GMP::Z.new(1) #=> 1 (Ruby Fixnum)
@@ -180,4 +182,55 @@ GMP::Z.new(GMP::Z.new(31)) #=> 31 (GMP Integer)
180
182
 
181
183
  There is also a convenience method available, \texttt{GMP::Z()}.\\
182
184
 
185
+ \subsection{Converting Integers}
186
+
187
+ \large{\textbf{integer.to\_d -> Float}}\\
188
+ Returns \texttt{integer} as an Float if \texttt{integer} fits in a Float.\\
189
+ \\
190
+ Otherwise returns the least significant part of \texttt{integer}, with the same sign as
191
+ \texttt{integer}.\\
192
+ \\
193
+ If \texttt{integer} is too big to fit in a Float, the returned result is probably not
194
+ very useful. To find out if the value will fit, use the function
195
+ \texttt{mpz\_fits\_slong\_p} (\textbf{Unimplemented}).\\
196
+ \\
197
+ \large{\textbf{integer.to\_i -> Fixnum}}\\
198
+ Returns \texttt{integer} as a Fixnum if \texttt{integer} fits in a Fixnum.\\
199
+ \\
200
+ Otherwise returns the least significant part of \texttt{integer}, with the same sign as
201
+ \texttt{integer}.\\
202
+ \\
203
+ If \texttt{integer} is too big to fit in a Fixnum, the returned result is probably not
204
+ very useful. To find out if the value will fit, use the function
205
+ \texttt{mpz\_fits\_slong\_p} (\textbf{Unimplemented}).\\
206
+ \\
207
+ \large{\textbf{integer.to\_s(base = 10) -> String}}\\
208
+ Returns \texttt{integer}, as a Ruby string. If \texttt{base} is not provided, then the
209
+ string will be the decimal representation.\\
210
+ \\
211
+ From the GMP Manual:\\
212
+ \\
213
+ Convert \texttt{integer} to a string of digits in base \texttt{base}. The \texttt{base}
214
+ argument may vary from 2 to 62 or from -2 to -36.\\
215
+ \\
216
+ For \texttt{base} in the range 2..36, digits and lower-case letters are used; for
217
+ -2..-36, digits and upper-case letters are used; for 37..62, digits, upper-case letters,
218
+ and lower-case letters (in that significance order) are used.\\
219
+
220
+ \subsection{Integer Arithmetic}
221
+
222
+ \large{\textbf{integer.add(b)}}\\
223
+ \large{\textbf{integer + b}}\\
224
+ \large{\textbf{integer.add!(b)}}\\
225
+ Adds \texttt{integer} to \texttt{b}. \texttt{add} and \texttt{+} return the result.
226
+ \texttt{add!} sets \texttt{integer} to the result. \texttt{b} can be a member of one of
227
+ the following classes:
228
+ \begin{verbatim}
229
+ GMP::Z
230
+ Fixnum
231
+ GMP::Q
232
+ GMP::F
233
+ Bignum
234
+ \end{verbatim}
235
+
183
236
  \end{document}
@@ -22,8 +22,8 @@ Tests:
22
22
  14* shifts, last_bits
23
23
  15* logical tests, roots
24
24
  16* floating point init with and without explicit precision
25
- 17 basic floating point arithmetics and coersion to F
26
- 18 default_prec and default_prec=
25
+ 17* basic floating point arithmetics and coersion to F
26
+ 18* default_prec and default_prec=
27
27
  19 integer division methods
28
28
  20 mpfr - exp and log
29
29
  21 mpfr - trigonometry
@@ -0,0 +1,71 @@
1
+ require 'test_helper'
2
+
3
+ class TC_F_arithmetics_coersion < Test::Unit::TestCase
4
+ def setup
5
+ @a = GMP::F.new(3.14, 100)
6
+ @b = GMP::F.new(2.71, 200)
7
+ @c = GMP::Z(3)
8
+ @d = GMP::Q(7,2)
9
+ @e = 2**32
10
+ end
11
+
12
+ def test_add
13
+ assert_in_delta( 5.85, @a + @b, 1e-6)
14
+ assert_in_delta( 5.85, @b + @a, 1e-6)
15
+ assert_in_delta( 6.14, @a + @c, 1e-6)
16
+ assert_in_delta( 6.14, @c + @a, 1e-6)
17
+ assert_in_delta( 6.64, @a + @d, 1e-6)
18
+ assert_in_delta( 6.64, @d + @a, 1e-6)
19
+ assert_in_delta( 5.14, @a + 2, 1e-6)
20
+ assert_in_delta( 5.14, 2 + @a, 1e-6)
21
+ assert_in_delta(4294967299.14, @a + @e, 1e-6)
22
+ assert_in_delta(4294967299.14, @e + @a, 1e-6)
23
+ assert_in_delta( 7.65, @a + 4.51, 1e-6)
24
+ assert_in_delta( 7.65, 4.51 + @a, 1e-6)
25
+ end
26
+
27
+ def test_sub
28
+ assert_in_delta( 0.43, @a - @b, 1e-6)
29
+ assert_in_delta( -0.43, @b - @a, 1e-6)
30
+ assert_in_delta( 0.14, @a - @c, 1e-6)
31
+ assert_in_delta( -0.14, @c - @a, 1e-6)
32
+ assert_in_delta( -0.36, @a - @d, 1e-6)
33
+ assert_in_delta( 0.36, @d - @a, 1e-6)
34
+ assert_in_delta( 1.14, @a - 2, 1e-6)
35
+ assert_in_delta( -1.14, 2 - @a, 1e-6)
36
+ assert_in_delta(-4294967292.86, @a - @e, 1e-6)
37
+ assert_in_delta( 4294967292.86, @e - @a, 1e-6)
38
+ assert_in_delta( -1.37, @a - 4.51, 1e-6)
39
+ assert_in_delta( 1.37, 4.51 - @a, 1e-6)
40
+ end
41
+
42
+ def test_mul
43
+ assert_in_delta( 8.5094, @a * @b, 1e-6)
44
+ assert_in_delta( 8.5094, @b * @a, 1e-6)
45
+ assert_in_delta( 9.42 , @a * @c, 1e-6)
46
+ assert_in_delta( 9.42 , @c * @a, 1e-6)
47
+ assert_in_delta( 10.99 , @a * @d, 1e-6)
48
+ assert_in_delta( 10.99 , @d * @a, 1e-6)
49
+ assert_in_delta( 6.28 , @a * 2, 1e-6)
50
+ assert_in_delta( 6.28 , 2 * @a, 1e-6)
51
+ assert_in_delta(13486197309.44 , @a * @e, 1e-6)
52
+ assert_in_delta(13486197309.44 , @e * @a, 1e-6)
53
+ assert_in_delta( 14.1614, @a * 4.51, 1e-6)
54
+ assert_in_delta( 14.1614, 4.51 * @a, 1e-6)
55
+ end
56
+
57
+ def test_div
58
+ assert_in_delta( 1.1586715867, @a / @b, 1e-6)
59
+ assert_in_delta( 0.8630573248, @b / @a, 1e-6)
60
+ assert_in_delta( 1.0466666667, @a / @c, 1e-6)
61
+ assert_in_delta( 0.9554140127, @c / @a, 1e-6)
62
+ assert_in_delta( 0.8971428571, @a / @d, 1e-6)
63
+ assert_in_delta( 1.1146496815, @d / @a, 1e-6)
64
+ assert_in_delta( 1.57 , @a / 2, 1e-6)
65
+ assert_in_delta( 0.6369426752, 2 / @a, 1e-6)
66
+ assert_in_delta( 0.0000000007, @a / @e, 1e-6)
67
+ assert_in_delta( 1367823979.6178343949, @e / @a, 1e-6)
68
+ assert_in_delta( 0.6962305987, @a / 4.51, 1e-6)
69
+ assert_in_delta( 1.4363057325, 4.51 / @a, 1e-6)
70
+ end
71
+ end
@@ -0,0 +1,48 @@
1
+ require 'test_helper'
2
+
3
+ class TC_precision < Test::Unit::TestCase
4
+ def setup
5
+ @pi = GMP::F.new(3.14)
6
+ @seven_halves = GMP::F.new(GMP::Q.new(7,2), 1000)
7
+ end
8
+
9
+ def test_default_precision
10
+ assert_equal("0.e+0", GMP::F.new().to_s)
11
+ assert_equal(64, GMP::F.new().prec)
12
+ assert_equal("0.314000000000000012434e+1", @pi.to_s)
13
+ assert_equal(64, @pi.prec)
14
+ assert_equal("0.1e+1", GMP::F.new(1).to_s)
15
+ assert_equal(64, GMP::F.new(1).prec)
16
+ assert_equal("0.314e+1", GMP::F.new("3.14").to_s)
17
+ assert_equal(64, GMP::F.new("3.14").prec)
18
+ assert_equal("0.4294967296e+10", GMP::F.new(2**32).to_s)
19
+ assert_equal(64, GMP::F.new(2**32).prec)
20
+ assert_equal("0.3e+1", GMP::F.new(GMP::Z.new(3)).to_s)
21
+ assert_equal(64, GMP::F.new(GMP::Z.new(3)).prec)
22
+ assert_equal("0.35e+1", GMP::F.new(GMP::Q.new(7,2)).to_s)
23
+ assert_equal(64, GMP::F.new(GMP::Q.new(7,2)).prec)
24
+ assert_equal("0.314000000000000012434e+1", GMP::F.new(@pi).to_s)
25
+ assert_equal(64, GMP::F.new(@pi).prec)
26
+ end
27
+
28
+ def test_specific_precision
29
+ assert_equal("0.3140000000000000124344978758017532527446746826171875e+1", GMP::F.new(3.14, 1000).to_s)
30
+ assert_equal(1024, GMP::F.new(3.14, 1000).prec)
31
+ assert_equal("0.1e+1", GMP::F.new(1, 1000).to_s)
32
+ assert_equal(1024, GMP::F.new(1, 1000).prec)
33
+ assert_equal("0.314e+1", GMP::F.new("3.14", 1000).to_s)
34
+ assert_equal(1024, GMP::F.new("3.14", 1000).prec)
35
+ assert_equal("0.4294967296e+10", GMP::F.new(2**32, 1000).to_s)
36
+ assert_equal(1024, GMP::F.new(2**32, 1000).prec)
37
+ assert_equal("0.3e+1", GMP::F.new(GMP::Z.new(3), 1000).to_s)
38
+ assert_equal(1024, GMP::F.new(GMP::Z.new(3), 1000).prec)
39
+ assert_equal("0.35e+1", @seven_halves.to_s)
40
+ assert_equal(1024, @seven_halves.prec)
41
+ assert_equal("0.35e+1", GMP::F.new(@seven_halves).to_s)
42
+ assert_equal(1024, GMP::F.new(@seven_halves).prec)
43
+ assert_equal("0.3140000000000000124344978758017532527446746826171875e+1", GMP::F.new(@pi, 1000).to_s)
44
+ assert_equal(1024, GMP::F.new(@pi, 1000).prec)
45
+ assert_equal("0.35e+1", GMP::F.new(@seven_halves, 0).to_s)
46
+ assert_equal(64, GMP::F.new(@seven_halves, 0).prec)
47
+ end
48
+ end
@@ -16,120 +16,84 @@ require 'tc_floor_ceil_truncate'
16
16
  require 'tc_z_to_d_to_i'
17
17
  require 'tc_z_shifts_last_bits'
18
18
  require 'tc_logical_roots'
19
+ require 'tc_f_precision'
20
+ require 'tc_f_arithmetics_coersion'
19
21
 
20
- class TC_precision < Test::Unit::TestCase
21
- def setup
22
- @pi = GMP::F.new(3.14)
23
- @seven_halves = GMP::F.new(GMP::Q.new(7,2), 1000)
24
- end
25
-
26
- def test_default_precision
27
- assert_equal("0.e+0", GMP::F.new().to_s)
28
- assert_equal(64, GMP::F.new().prec)
29
- assert_equal("0.314000000000000012434e+1", @pi.to_s)
30
- assert_equal(64, @pi.prec)
31
- assert_equal("0.1e+1", GMP::F.new(1).to_s)
32
- assert_equal(64, GMP::F.new(1).prec)
33
- assert_equal("0.314e+1", GMP::F.new("3.14").to_s)
34
- assert_equal(64, GMP::F.new("3.14").prec)
35
- assert_equal("0.4294967296e+10", GMP::F.new(2**32).to_s)
36
- assert_equal(64, GMP::F.new(2**32).prec)
37
- assert_equal("0.3e+1", GMP::F.new(GMP::Z.new(3)).to_s)
38
- assert_equal(64, GMP::F.new(GMP::Z.new(3)).prec)
39
- assert_equal("0.35e+1", GMP::F.new(GMP::Q.new(7,2)).to_s)
40
- assert_equal(64, GMP::F.new(GMP::Q.new(7,2)).prec)
41
- assert_equal("0.314000000000000012434e+1", GMP::F.new(@pi).to_s)
42
- assert_equal(64, GMP::F.new(@pi).prec)
43
- end
44
-
45
- def test_specific_precision
46
- assert_equal("0.3140000000000000124344978758017532527446746826171875e+1", GMP::F.new(3.14, 1000).to_s)
47
- assert_equal(1024, GMP::F.new(3.14, 1000).prec)
48
- assert_equal("0.1e+1", GMP::F.new(1, 1000).to_s)
49
- assert_equal(1024, GMP::F.new(1, 1000).prec)
50
- assert_equal("0.314e+1", GMP::F.new("3.14", 1000).to_s)
51
- assert_equal(1024, GMP::F.new("3.14", 1000).prec)
52
- assert_equal("0.4294967296e+10", GMP::F.new(2**32, 1000).to_s)
53
- assert_equal(1024, GMP::F.new(2**32, 1000).prec)
54
- assert_equal("0.3e+1", GMP::F.new(GMP::Z.new(3), 1000).to_s)
55
- assert_equal(1024, GMP::F.new(GMP::Z.new(3), 1000).prec)
56
- assert_equal("0.35e+1", @seven_halves.to_s)
57
- assert_equal(1024, @seven_halves.prec)
58
- assert_equal("0.35e+1", GMP::F.new(@seven_halves).to_s)
59
- assert_equal(1024, GMP::F.new(@seven_halves).prec)
60
- assert_equal("0.3140000000000000124344978758017532527446746826171875e+1", GMP::F.new(@pi, 1000).to_s)
61
- assert_equal(1024, GMP::F.new(@pi, 1000).prec)
62
- assert_equal("0.35e+1", GMP::F.new(@seven_halves, 0).to_s)
63
- assert_equal(64, GMP::F.new(@seven_halves, 0).prec)
22
+ class TC_default_prec < Test::Unit::TestCase
23
+ def test_default_prec
24
+ assert_equal( 64, GMP::F.default_prec, "GMP::F.default_prec should be 64.")
25
+ GMP::F.default_prec = 100
26
+ assert_equal(128, GMP::F.default_prec, "GMP::F.default_prec should be assignable.")
27
+ GMP::F.default_prec = 64
64
28
  end
65
29
  end
66
30
 
67
- class TC_F_arithmetics_coersion < Test::Unit::TestCase
31
+ class TC_division < Test::Unit::TestCase
68
32
  def setup
69
- @a = GMP::F.new(3.14, 100)
70
- @b = GMP::F.new(2.71, 200)
71
- @c = GMP::Z(3)
72
- @d = GMP::Q(7,2)
73
- @e = 2**32
33
+ @a = GMP::Z.new(5)
34
+ @b = GMP::Z.new(7)
35
+ @c = GMP::Z.new(25)
36
+ @d = GMP::Q.new(3,11)
37
+ @e = GMP::F.new(3.14)
38
+ @f = 2**32
39
+ end
40
+
41
+ def test_z_div
42
+ assert_equal(GMP::Q, (@a / @b ).class, "GMP::Z / GMP::Z should be GMP::Q.")
43
+ assert_equal(GMP::Q, (@a / 3 ).class, "GMP::Z / Fixnum should be GMP::Q.")
44
+ assert_equal(GMP::Q, (@a / 2**32).class, "GMP::Z / Bignum should be GMP::Q.")
45
+ assert_equal(GMP::Q, (@a / @c ).class, "GMP::Z / GMP::Z should be GMP::Q.")
46
+ assert_in_delta(0.7142857142, @a / @b, 1e-7, "GMP::Z./ should work.")
47
+ assert_in_delta(1.4 , @b / @a, 1e-7, "GMP::Z./ should work.")
48
+ assert_in_delta(1.6666666667, @a / 3, 1e-7, "GMP::Z./ should work.")
49
+ assert_in_delta(0.6 , 3 / @a, 1e-7, "GMP::Z./ should work.")
50
+ assert_in_delta(0.2 , @a / @c, 1e-7, "GMP::Z./ should work.")
51
+ assert_in_delta(5.0 , @c / @a, 1e-7, "GMP::Z./ should work.")
74
52
  end
75
53
 
76
- def test_add
77
- assert_in_delta( 5.85, @a + @b, 1e-6)
78
- assert_in_delta( 5.85, @b + @a, 1e-6)
79
- assert_in_delta( 6.14, @a + @c, 1e-6)
80
- assert_in_delta( 6.14, @c + @a, 1e-6)
81
- assert_in_delta( 6.64, @a + @d, 1e-6)
82
- assert_in_delta( 6.64, @d + @a, 1e-6)
83
- assert_in_delta( 5.14, @a + 2, 1e-6)
84
- assert_in_delta( 5.14, 2 + @a, 1e-6)
85
- assert_in_delta(4294967299.14, @a + @e, 1e-6)
86
- assert_in_delta(4294967299.14, @e + @a, 1e-6)
87
- assert_in_delta( 7.65, @a + 4.51, 1e-6)
88
- assert_in_delta( 7.65, 4.51 + @a, 1e-6)
54
+ def test_z_tdiv
55
+ assert_equal(GMP::Z, @a.tdiv(@b).class, "GMP::Z.tdiv GMP::Z should be GMP::Z.")
56
+ assert_equal(GMP::Z, @a.tdiv(3).class, "GMP::Z.tdiv Fixnum should be GMP::Z.")
57
+ assert_equal(GMP::Z, @a.tdiv(2**32).class, "GMP::Z.tdiv Bignum should be GMP::Z.")
58
+ assert_equal(GMP::Z, @a.tdiv(@c).class, "GMP::Z.tdiv GMP::Z should be GMP::Z.")
59
+ assert_equal(0, @a.tdiv(@b), "GMP::Z.tdiv should work.")
60
+ assert_equal(1, @b.tdiv(@a), "GMP::Z.tdiv should work.")
61
+ assert_equal(1, @a.tdiv( 3), "GMP::Z.tdiv should work.")
62
+ assert_equal(0, @a.tdiv(@c), "GMP::Z.tdiv should work.")
63
+ assert_equal(5, @c.tdiv(@a), "GMP::Z.tdiv should work.")
89
64
  end
90
65
 
91
- def test_sub
92
- assert_in_delta( 0.43, @a - @b, 1e-6)
93
- assert_in_delta( -0.43, @b - @a, 1e-6)
94
- assert_in_delta( 0.14, @a - @c, 1e-6)
95
- assert_in_delta( -0.14, @c - @a, 1e-6)
96
- assert_in_delta( -0.36, @a - @d, 1e-6)
97
- assert_in_delta( 0.36, @d - @a, 1e-6)
98
- assert_in_delta( 1.14, @a - 2, 1e-6)
99
- assert_in_delta( -1.14, 2 - @a, 1e-6)
100
- assert_in_delta(-4294967292.86, @a - @e, 1e-6)
101
- assert_in_delta( 4294967292.86, @e - @a, 1e-6)
102
- assert_in_delta( -1.37, @a - 4.51, 1e-6)
103
- assert_in_delta( 1.37, 4.51 - @a, 1e-6)
66
+ def test_z_fdiv
67
+ assert_equal(GMP::Z, @a.fdiv(@b).class, "GMP::Z.fdiv GMP::Z should be GMP::Z.")
68
+ assert_equal(GMP::Z, @a.fdiv(3).class, "GMP::Z.fdiv Fixnum should be GMP::Z.")
69
+ assert_equal(GMP::Z, @a.fdiv(2**32).class, "GMP::Z.fdiv Bignum should be GMP::Z.")
70
+ assert_equal(0, @a.fdiv(@b), "GMP::Z.fdiv should work.")
71
+ assert_equal(1, @b.fdiv(@a), "GMP::Z.fdiv should work.")
72
+ assert_equal(1, @a.fdiv( 3), "GMP::Z.fdiv should work.")
73
+ assert_equal(0, @a.fdiv(@c), "GMP::Z.fdiv should work.")
74
+ assert_equal(5, @c.fdiv(@a), "GMP::Z.fdiv should work.")
104
75
  end
105
76
 
106
- def test_mul
107
- assert_in_delta( 8.5094, @a * @b, 1e-6)
108
- assert_in_delta( 8.5094, @b * @a, 1e-6)
109
- assert_in_delta( 9.42 , @a * @c, 1e-6)
110
- assert_in_delta( 9.42 , @c * @a, 1e-6)
111
- assert_in_delta( 10.99 , @a * @d, 1e-6)
112
- assert_in_delta( 10.99 , @d * @a, 1e-6)
113
- assert_in_delta( 6.28 , @a * 2, 1e-6)
114
- assert_in_delta( 6.28 , 2 * @a, 1e-6)
115
- assert_in_delta(13486197309.44 , @a * @e, 1e-6)
116
- assert_in_delta(13486197309.44 , @e * @a, 1e-6)
117
- assert_in_delta( 14.1614, @a * 4.51, 1e-6)
118
- assert_in_delta( 14.1614, 4.51 * @a, 1e-6)
77
+ def test_z_cdiv
78
+ assert_equal(GMP::Z, @a.cdiv(@b).class, "GMP::Z.cdiv GMP::Z should be GMP::Z.")
79
+ assert_equal(GMP::Z, @a.cdiv(3).class, "GMP::Z.cdiv Fixnum should be GMP::Z.")
80
+ assert_equal(GMP::Z, @a.cdiv(2**32).class, "GMP::Z.cdiv Bignum should be GMP::Z.")
81
+ assert_equal(1, @a.cdiv(@b), "GMP::Z.cdiv should work.")
82
+ assert_equal(2, @b.cdiv(@a), "GMP::Z.cdiv should work.")
83
+ assert_equal(2, @a.cdiv( 3), "GMP::Z.cdiv should work.")
84
+ assert_equal(1, @a.cdiv(@c), "GMP::Z.cdiv should work.")
85
+ assert_equal(5, @c.cdiv(@a), "GMP::Z.cdiv should work.")
119
86
  end
120
87
 
121
- def test_div
122
- assert_in_delta( 1.1586715867, @a / @b, 1e-6)
123
- assert_in_delta( 0.8630573248, @b / @a, 1e-6)
124
- assert_in_delta( 1.0466666667, @a / @c, 1e-6)
125
- assert_in_delta( 0.9554140127, @c / @a, 1e-6)
126
- assert_in_delta( 0.8971428571, @a / @d, 1e-6)
127
- assert_in_delta( 1.1146496815, @d / @a, 1e-6)
128
- assert_in_delta( 1.57 , @a / 2, 1e-6)
129
- assert_in_delta( 0.6369426752, 2 / @a, 1e-6)
130
- assert_in_delta( 0.0000000007, @a / @e, 1e-6)
131
- assert_in_delta( 1367823979.6178343949, @e / @a, 1e-6)
132
- assert_in_delta( 0.6962305987, @a / 4.51, 1e-6)
133
- assert_in_delta( 1.4363057325, 4.51 / @a, 1e-6)
88
+ def test_z_tmod
89
+ assert_equal(GMP::Z, @a.tmod(@b).class, "GMP::Z.tmod GMP::Z should be GMP::Z.")
90
+ assert_equal(GMP::Z, @a.tmod(3).class, "GMP::Z.tmod Fixnum should be GMP::Z.")
91
+ assert_equal(GMP::Z, @a.tmod(2**32).class, "GMP::Z.tmod Bignum should be GMP::Z.")
92
+ assert_equal(GMP::Z, @a.tmod(@c).class, "GMP::Z.tmod GMP::Z should be GMP::Z.")
93
+ assert_equal(5, @a.tmod(@b), "GMP::Z.tmod should work.")
94
+ assert_equal(2, @b.tmod(@a), "GMP::Z.tmod should work.")
95
+ assert_equal(2, @a.tmod( 3), "GMP::Z.tmod should work.")
96
+ assert_equal(5, @a.tmod(@c), "GMP::Z.tmod should work.")
97
+ assert_equal(0, @c.tmod(@a), "GMP::Z.tmod should work.")
134
98
  end
135
99
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gmp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomasz Wegrzanowski
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-10-01 00:00:00 -07:00
13
+ date: 2009-10-20 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
 
@@ -37,6 +37,8 @@ files:
37
37
  - ext/takeover.h
38
38
  - test/README
39
39
  - test/tc_cmp.rb
40
+ - test/tc_f_precision.rb
41
+ - test/tc_f_arithmetics_coersion.rb
40
42
  - test/tc_fib_fac_nextprime.rb
41
43
  - test/tc_floor_ceil_truncate.rb
42
44
  - test/tc_logical_roots.rb
@@ -58,7 +60,7 @@ files:
58
60
  - README.rdoc
59
61
  - manual.tex
60
62
  has_rdoc: false
61
- homepage: http://github.com/srawlins/gmp/tree/master
63
+ homepage: http://github.com/srawlins/gmp
62
64
  licenses: []
63
65
 
64
66
  post_install_message: