gmp 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. data/CHANGELOG +4 -1
  2. data/manual.pdf +0 -0
  3. data/manual.tex +293 -79
  4. data/test/unit_tests.rb +24 -0
  5. metadata +3 -2
data/CHANGELOG CHANGED
@@ -1,4 +1,7 @@
1
- 0.18:
1
+ 0.1.9:
2
+ * Cleaning up more documentation in PDF format.
3
+
4
+ 0.1.8:
2
5
  * Added test: tc_division, in progress.
3
6
  * Unit test results: 56 tests, 361 assertions, 0 failures, 0 errors
4
7
  * Added to_f ==> to_d aliases for GMP::Q and GMP::F.
Binary file
data/manual.tex CHANGED
@@ -1,23 +1,33 @@
1
1
  \documentclass[pdftex,10pt]{article}
2
2
  \usepackage{amsmath,amsfonts,url}
3
3
  \usepackage[pdftex]{graphicx}
4
+ \usepackage{booktabs}
5
+ \usepackage{url}
4
6
  \setlength{\parindent}{0pt}
5
- \newcommand{\HRule}{\rule{\linewidth}{0.8mm}}
6
- \newcommand{\sectionline}{\rule{1.0\linewidth}{2.0pt}}
7
7
  \def\cour{\fontfamily{pcr}\selectfont}
8
- \usepackage[top=1.2in, bottom=0.8in, left=0.8in, right=0.8in]{geometry}
8
+ \usepackage[top=1in, bottom=0.8in, left=0.8in, right=0.8in]{geometry}
9
9
  \setcounter{tocdepth}{3}
10
- \title{gmp - Ruby bindings to the GMP library}
11
- \date{September 27, 2009}
12
- \author{Sam Rawlins}
10
+ \newlength{\titrwidth}
11
+ \setlength{\titrwidth}{\textwidth}
12
+ \addtolength{\titrwidth}{-1.2in}
13
+ \newlength{\methwidth}
14
+ \setlength{\methwidth}{0.8in}
15
+ \newlength{\defnwidth}
16
+ \setlength{\defnwidth}{\textwidth}
17
+ \addtolength{\defnwidth}{-1.2in}
18
+ \addtolength{\heavyrulewidth}{\heavyrulewidth}
19
+ \def\qquad{\quad\quad}
20
+ \def\qqqquad{\quad\quad\quad\quad}
13
21
  \begin{document}
14
- \huge{gmp}\\
15
- \HRule
16
- \begin{flushright}
17
- \large{Ruby bindings to the GMP library}\\
18
- \large{Edition 0.1.5}\\
19
- \large{27 September 2009}\\
20
- \end{flushright}
22
+
23
+ \begin{tabular}{p{1.0in} p{\titrwidth}}
24
+ \huge{gmp} &\\
25
+ \midrule[3pt]
26
+ \multicolumn{2}{r}{\large{Ruby bindings to the GMP library}}\\
27
+ \multicolumn{2}{r}{\large{Edition 0.1.9}}\\
28
+ \multicolumn{2}{r}{\large{23 November 2009}}
29
+ \end{tabular}
30
+
21
31
  \vfill
22
32
  \large{written by Sam Rawlins}\\
23
33
  \large{with extensive quoting from the GMP Manual}
@@ -63,13 +73,17 @@ Some optimizations also for Cray vector systems, Clipper, IBM ROMP (RT), and
63
73
  Pyramid AP/XP.\\
64
74
  \\
65
75
  For up-to-date information on GMP, please see the GMP web pages at\\
76
+ \setlength{\parindent}{0.25in}
77
+ \texttt{http://gmplib.org/}
78
+ \setlength{\parindent}{0in}
66
79
  \\
67
- \indent \texttt{http://gmplib.org/}\\
68
80
 
69
81
  The latest version of the library is available at\\
70
- \\
82
+ \setlength{\parindent}{0.25in}
71
83
  \texttt{ftp://ftp.gnu.org/gnu/gmp/}\\
84
+ \setlength{\parindent}{0in}
72
85
  \\
86
+
73
87
  Many sites around the world mirror '\texttt{ftp.gnu.org}', please use a mirror
74
88
  near you, see \texttt{http://www.gnu.org/order/ftp.html} for a full list.\\
75
89
  \\
@@ -119,8 +133,8 @@ That's all. I don't intend to test any older versions, maybe 4.3.0 for completen
119
133
 
120
134
  Here is a table of the exact environments I have tested the gmp gem on:\\\\
121
135
 
122
- \begin{tabular}{|l|r|r|} \hline
123
- Platform & Ruby & GMP \\ \hline \hline
136
+ \begin{tabular}{lrr} \hline
137
+ Platform & Ruby & GMP \\ \midrule[1pt]
124
138
  Cygwin on x86 & (MRI) Ruby 1.8.7 & GMP 4.3.1 \\ \hline
125
139
  Linux (LinuxMint 7) on x86 & (MRI) Ruby 1.8.7 & GMP 4.3.1 \\ \hline
126
140
  Mac OS X 10.5.7 on x86 (32-bit) & (MRI) Ruby 1.8.6 & GMP 4.3.1 \\ \hline
@@ -130,18 +144,18 @@ Here is a table of the exact environments I have tested the gmp gem on:\\\\
130
144
  \subsection{Installing}
131
145
  You may clone the gmp gem's git repository with:\\
132
146
  \\
133
- \hangindent=0.5cm \texttt{git clone git://github.com/srawlins/gmp.git}\\
147
+ \texttt{git clone git://github.com/srawlins/gmp.git}\\
134
148
 
135
149
  Or you may install the gem from github:\\
136
150
  \\
137
- \hangindent=0.5cm \texttt{gem install srawlins-gmp}\\
151
+ \texttt{gem install srawlins-gmp}\\
138
152
 
139
153
  At this time, the gem does not self-compile (how does that work?). To compile the C
140
154
  extensions, do the following:\\
141
155
  \\
142
- \hangindent=0.5cm \texttt{cd <srawlins-gmp gem directory>/ext}\\
143
- \hangindent=0.5cm \texttt{ruby extconf.rb}\\
144
- \hangindent=0.5cm \texttt{make}\\
156
+ \texttt{cd <srawlins-gmp gem directory>/ext}\\
157
+ \texttt{ruby extconf.rb}\\
158
+ \texttt{make}\\
145
159
 
146
160
  There shouldn't be any errors, or warnings.
147
161
 
@@ -163,74 +177,274 @@ In addition to the above three classes, there is also one constant within \textt
163
177
  \item \texttt{GMP::GMP\_VERSION} - The version of GMP compiled into the gmp gem.
164
178
  \end{itemize}
165
179
 
180
+ \newpage
166
181
  \section{Integer Functions}
167
182
 
168
183
  \subsection{Initializing, Assigning Integers}
169
184
 
170
- \large{\textbf{GMP::Z.new(a = 0)}}\\
171
- \large{\textbf{GMP::Z(a = 0)}}\\
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:
175
- \begin{verbatim}
176
- GMP::Z.new #=> 0 (default)
177
- GMP::Z.new(1) #=> 1 (Ruby Fixnum)
178
- GMP::Z.new("127") #=> 127 (Ruby String)
179
- GMP::Z.new(4294967296) #=> 4294967296 (Ruby Bignum)
180
- GMP::Z.new(GMP::Z.new(31)) #=> 31 (GMP Integer)
181
- \end{verbatim}
185
+ \begin{tabular}{p{\methwidth} l r}
186
+ \toprule
187
+ \textbf{new} & & GMP::Z.new $\rightarrow$ \textit{integer} \\
188
+ & & GMP::Z.new(\textit{numeric = 0}) $\rightarrow$ \textit{integer} \\
189
+ & & GMP::Z.new(\textit{str}) $\rightarrow$ \textit{integer} \\
190
+ \cmidrule(r){2-3}
191
+ & \multicolumn{2}{p{\defnwidth}}{
192
+ This method creates a new \textit{GMP::Z} integer. It takes one optional argument for
193
+ the value of the integer. This argument can be one of several classes. Here are some
194
+ examples:\newline
195
+
196
+ \texttt{GMP::Z.new \qqqquad\qqqquad \#=> 0 (default) \newline
197
+ GMP::Z.new(1) \qqqquad\qquad\ \#=> 1 (Ruby Fixnum) \newline
198
+ GMP::Z.new("127") \qqqquad\ \#=> 127 (Ruby String)\newline
199
+ GMP::Z.new(4294967296) \qquad \#=> 4294967296 (Ruby Bignum)\newline
200
+ GMP::Z.new(GMP::Z.new(31)) \#=> 31 (GMP Integer)}
201
+ }
202
+ \end{tabular}
203
+ \newline\newline
182
204
 
183
205
  There is also a convenience method available, \texttt{GMP::Z()}.\\
184
206
 
185
207
  \subsection{Converting Integers}
186
208
 
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.\\
209
+ \begin{tabular}{p{\methwidth} l r}
210
+ \toprule
211
+ \textbf{to\_d} & & \textit{integer}.to\_d $\rightarrow$ \textit{float} \\
212
+ \cmidrule(r){2-3}
213
+ & \multicolumn{2}{p{\defnwidth}}{
214
+ Returns \textit{integer} as an Float if \textit{integer} fits in a Float.
215
+
216
+ Otherwise returns the least significant part of \texttt{integer}, with the same sign as
217
+ \textit{integer}.
218
+
219
+ If \textit{integer} is too big to fit in a Float, the returned result is probably not
220
+ very useful. To find out if the value will fit, use the function
221
+ \textit{mpz\_fits\_slong\_p} (\textbf{Unimplemented}).
222
+ }
223
+ \end{tabular}
224
+ \newline\newline
225
+
226
+ \begin{tabular}{p{\methwidth} l r}
227
+ \toprule
228
+ \textbf{to\_i} & & \textit{integer}.to\_i $\rightarrow$ \textit{fixnum} \\
229
+ \cmidrule(r){2-3}
230
+ & \multicolumn{2}{p{\defnwidth}}{
231
+ Returns \textit{integer} as a Fixnum if \textit{integer} fits in a Fixnum.
232
+ \newline
233
+
234
+ Otherwise returns the least significant part of \textit{integer}, with the same sign as
235
+ \textit{integer}.
236
+ \newline
237
+
238
+ If \textit{integer} is too big to fit in a Fixnum, the returned result is probably not
239
+ very useful. To find out if the value will fit, use the function
240
+ \textit{mpz\_fits\_slong\_p} (\textbf{Unimplemented}).
241
+ }
242
+ \end{tabular}
243
+ \newline\newline
244
+
245
+ \begin{tabular}{p{\methwidth} l r}
246
+ \toprule
247
+ \textbf{to\_s} & & \textit{integer}.to\_s(\textit{base = 10}) $\rightarrow$ \textit{str} \\
248
+ \cmidrule(r){2-3}
249
+ & \multicolumn{2}{p{\defnwidth}}{
250
+ Converts \textit{integer} to a string of digits in base \textit{base}. The
251
+ \textit{base} argument may vary from 2 to 62 or from -2 to -36, or be a symbol, one of
252
+ \textit{:bin}, \textit{:oct}, \textit{:dec}, or \textit{:hex}.
253
+ \newline
254
+
255
+ For \textit{base} in the range 2..36, digits and lower-case letters are used; for
256
+ -2..-36 (and \textit{:bin}, \textit{:oct}, \textit{:dec}, and \textit{:hex}), digits
257
+ and upper-case letters are used; for 37..62, digits, upper-case letters, and lower-case
258
+ letters (in that significance order) are used. Here are some
259
+ examples:\newline
260
+
261
+ \texttt{GMP::Z(1).to\_s \qqqquad \#=> "1" \newline
262
+ GMP::Z(32).to\_s(2) \qquad \#=> "100000" \newline
263
+ GMP::Z(32).to\_s(4) \qquad \#=> "200" \newline
264
+ GMP::Z(10).to\_s(16) \quad\ \#=> "a" \newline
265
+ GMP::Z(10).to\_s(-16) \quad \#=> "A" \newline
266
+ GMP::Z(255).to\_s(:bin) \#=> "11111111" \newline
267
+ GMP::Z(255).to\_s(:oct) \#=> "377" \newline
268
+ GMP::Z(255).to\_s(:dec) \#=> "255" \newline
269
+ GMP::Z(255).to\_s(:hex) \#=> "ff"}
270
+ }
271
+ \end{tabular}
219
272
 
220
273
  \subsection{Integer Arithmetic}
221
274
 
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}
275
+ \begin{tabular}{p{\methwidth} l r}
276
+ \toprule
277
+ \textbf{+} & & \textit{integer} + \textit{numeric} $\rightarrow$ \textit{numeric} \\
278
+ \cmidrule(r){2-3}
279
+ & \multicolumn{2}{p{\defnwidth}}{
280
+ Returns the sum of \textit{integer} and \textit{numeric}. \textit{numeric} can be a
281
+ member of \textit{GMP::Z}, \textit{Fixnum}, \textit{GMP::Q}, \textit{GMP::F}, or
282
+ \textit{Bignum}.
283
+ }
284
+ \end{tabular}
285
+ \newline\newline
286
+
287
+ \begin{tabular}{p{\methwidth} l r}
288
+ \toprule
289
+ \textbf{add} & & \textit{integer}.add(\textit{numeric}) $\rightarrow$ \textit{numeric} \\
290
+ \cmidrule(r){2-3}
291
+ & \multicolumn{2}{p{\defnwidth}}{
292
+ Returns the sum of \textit{integer} and \textit{numeric}. \textit{numeric} can be a
293
+ member of \textit{GMP::Z}, \textit{Fixnum}, \textit{GMP::Q}, \textit{GMP::F}, or
294
+ \textit{Bignum}.
295
+ }
296
+ \end{tabular}
297
+ \newline\newline
298
+
299
+ \begin{tabular}{p{\methwidth} l r}
300
+ \toprule
301
+ \textbf{add!} & & \textit{integer}.add!(\textit{numeric}) $\rightarrow$
302
+ \textit{numeric} \\
303
+ \cmidrule(r){2-3}
304
+ & \multicolumn{2}{p{\defnwidth}}{
305
+ Sums \textit{integer} and \textit{numeric}, in place. \textit{numeric} can be a
306
+ member of \textit{GMP::Z}, \textit{Fixnum}, \textit{GMP::Q}, \textit{GMP::F}, or
307
+ \textit{Bignum}.
308
+ }
309
+ \end{tabular}
310
+ \newline\newline
311
+
312
+ \begin{tabular}{p{\methwidth} l r}
313
+ \toprule
314
+ \textbf{-} & & \textit{integer} - \textit{numeric} $\rightarrow$ \textit{numeric} \\
315
+ & & \textit{integer}.sub(\textit{numeric}) $\rightarrow$ \textit{numeric} \\
316
+ & & \textit{integer}.sub!(\textit{numeric}) $\rightarrow$ \textit{numeric} \\
317
+ \cmidrule(r){2-3}
318
+ & \multicolumn{2}{p{\defnwidth}}{
319
+ Returns the difference of \textit{integer} and \textit{numeric}. The destructive method
320
+ calculates the difference in place. \textit{numeric} can be a member of
321
+ \textit{GMP::Z}, \textit{Fixnum}, \textit{GMP::Q}, \textit{GMP::F}, or \textit{Bignum}.
322
+ }
323
+ \end{tabular}
324
+ \newline\newline
325
+
326
+ \begin{tabular}{p{\methwidth} l r}
327
+ \toprule
328
+ \textbf{*} & & \textit{integer} * \textit{numeric} $\rightarrow$ \textit{numeric} \\
329
+ & & \textit{integer}.mul(\textit{numeric}) $\rightarrow$ \textit{numeric} \\
330
+ & & \textit{integer}.mul!(\textit{numeric}) $\rightarrow$ \textit{numeric} \\
331
+ \cmidrule(r){2-3}
332
+ & \multicolumn{2}{p{\defnwidth}}{
333
+ Returns the product of \textit{integer} and \textit{numeric}. The destructive method
334
+ calculates the product in place. \textit{numeric} can be a member of \textit{GMP::Z},
335
+ \textit{Fixnum}, \textit{GMP::Q}, \textit{GMP::F}, or \textit{Bignum}.
336
+ }
337
+ \end{tabular}
338
+ \newline\newline
339
+
340
+ \begin{tabular}{p{\methwidth} l r}
341
+ \toprule
342
+ \textbf{-@} & & -\textit{integer}\\
343
+ & & \textit{integer}.neg\\
344
+ & & \textit{integer}.neg!\\
345
+ \cmidrule(r){2-3}
346
+ & \multicolumn{2}{p{\defnwidth}}{
347
+ Returns the negation, the additive inverse, of \textit{integer}. The destructive method
348
+ negates in place.
349
+ }
350
+ \end{tabular}
351
+ \newline\newline
352
+
353
+ \begin{tabular}{p{\methwidth} l r}
354
+ \toprule
355
+ \textbf{abs} & & \textit{integer}.abs\\
356
+ & & \textit{integer}.abs!\\
357
+ \cmidrule(r){2-3}
358
+ & \multicolumn{2}{p{\defnwidth}}{
359
+ Returns the absolute value of \textit{integer}. The destructive method calculates the
360
+ absolute value in place.
361
+ }
362
+ \end{tabular}
363
+
364
+ \subsection{Integer Division}
365
+
366
+ \begin{tabular}{p{\methwidth} l r}
367
+ \toprule
368
+ \textbf{tdiv} & & \textit{integer}.tdiv(\textit{numeric}) $\rightarrow$ \textit{integer}\\
369
+ \cmidrule(r){2-3}
370
+ & \multicolumn{2}{p{\defnwidth}}{
371
+ Returns the division of \textit{integer} by \textit{numeric}, truncated.
372
+ \textit{numeric} can be a member of \textit{GMP::Z}, \textit{Fixnum}, \textit{Bignum}.
373
+ The return object's class is always \textit{GMP::Z}.
374
+ }
375
+ \end{tabular}
376
+ \newline\newline
377
+
378
+ \begin{tabular}{p{\methwidth} l r}
379
+ \toprule
380
+ \textbf{fdiv} & & \textit{integer}.fdiv(\textit{numeric}) $\rightarrow$ \textit{integer}\\
381
+ \cmidrule(r){2-3}
382
+ & \multicolumn{2}{p{\defnwidth}}{
383
+ Returns the division of \textit{integer} by \textit{numeric}, floored.
384
+ \textit{numeric} can be a member of \textit{GMP::Z}, \textit{Fixnum}, \textit{Bignum}.
385
+ The return object's class is always \textit{GMP::Z}.
386
+ }
387
+ \end{tabular}
388
+ \newline\newline
389
+
390
+ \begin{tabular}{p{\methwidth} l r}
391
+ \toprule
392
+ \textbf{cdiv} & & \textit{integer}.cdiv(\textit{numeric}) $\rightarrow$ \textit{integer}\\
393
+ \cmidrule(r){2-3}
394
+ & \multicolumn{2}{p{\defnwidth}}{
395
+ Returns the ceiling division of \textit{integer} by \textit{numeric}.
396
+ \textit{numeric} can be a member of \textit{GMP::Z}, \textit{Fixnum}, \textit{Bignum}.
397
+ The return object's class is always \textit{GMP::Z}.
398
+ }
399
+ \end{tabular}
400
+ \newline\newline
401
+
402
+ \begin{tabular}{p{\methwidth} l r}
403
+ \toprule
404
+ \textbf{tmod} & & \textit{integer}.tmod(\textit{numeric}) $\rightarrow$ \textit{integer}\\
405
+ \cmidrule(r){2-3}
406
+ & \multicolumn{2}{p{\defnwidth}}{
407
+ Returns the remainder after truncated division of \textit{integer} by \textit{numeric}.
408
+ \textit{numeric} can be a member of \textit{GMP::Z}, \textit{Fixnum}, \textit{Bignum}.
409
+ The return object's class is always \textit{GMP::Z}.
410
+ }
411
+ \end{tabular}
412
+ \newline\newline
413
+
414
+ \begin{tabular}{p{\methwidth} l r}
415
+ \toprule
416
+ \textbf{fmod} & & \textit{integer}.fmod(\textit{numeric}) $\rightarrow$ \textit{integer}\\
417
+ \cmidrule(r){2-3}
418
+ & \multicolumn{2}{p{\defnwidth}}{
419
+ Returns the remainder after floored division of \textit{integer} by \textit{numeric}.
420
+ \textit{numeric} can be a member of \textit{GMP::Z}, \textit{Fixnum}, \textit{Bignum}.
421
+ The return object's class is always \textit{GMP::Z}.
422
+ }
423
+ \end{tabular}
424
+ \newline\newline
425
+
426
+ \begin{tabular}{p{\methwidth} l r}
427
+ \toprule
428
+ \textbf{cmod} & & \textit{integer}.cmod(\textit{numeric}) $\rightarrow$ \textit{integer}\\
429
+ \cmidrule(r){2-3}
430
+ & \multicolumn{2}{p{\defnwidth}}{
431
+ Returns the remainder after ceilinged division of \textit{integer} by \textit{numeric}.
432
+ \textit{numeric} can be a member of \textit{GMP::Z}, \textit{Fixnum}, \textit{Bignum}.
433
+ The return object's class is always \textit{GMP::Z}.
434
+ }
435
+ \end{tabular}
436
+
437
+ \subsection{Integer Exponentiation}
438
+
439
+ \subsection{Integer Roots}
440
+
441
+ \begin{tabular}{p{\methwidth} l r}
442
+ \toprule
443
+ \textbf{root} & & \textit{integer}.root(\textit{numeric}) $\rightarrow$ \textit{numeric} \\
444
+ \cmidrule(r){2-3}
445
+ & \multicolumn{2}{p{\defnwidth}}{
446
+ Returns the integer part of the \textit{numeric}'th root of \textit{integer}.
447
+ }
448
+ \end{tabular}
235
449
 
236
450
  \end{document}
@@ -96,4 +96,28 @@ class TC_division < Test::Unit::TestCase
96
96
  assert_equal(5, @a.tmod(@c), "GMP::Z.tmod should work.")
97
97
  assert_equal(0, @c.tmod(@a), "GMP::Z.tmod should work.")
98
98
  end
99
+
100
+ def test_z_fmod
101
+ assert_equal(GMP::Z, @a.fmod(@b).class, "GMP::Z.fmod GMP::Z should be GMP::Z.")
102
+ assert_equal(GMP::Z, @a.fmod(3).class, "GMP::Z.fmod Fixnum should be GMP::Z.")
103
+ assert_equal(GMP::Z, @a.fmod(2**32).class, "GMP::Z.fmod Bignum should be GMP::Z.")
104
+ assert_equal(GMP::Z, @a.fmod(@c).class, "GMP::Z.fmod GMP::Z should be GMP::Z.")
105
+ assert_equal(5, @a.fmod(@b), "GMP::Z.fmod should work.")
106
+ assert_equal(2, @b.fmod(@a), "GMP::Z.fmod should work.")
107
+ assert_equal(2, @a.fmod( 3), "GMP::Z.fmod should work.")
108
+ assert_equal(5, @a.fmod(@c), "GMP::Z.fmod should work.")
109
+ assert_equal(0, @c.fmod(@a), "GMP::Z.fmod should work.")
110
+ end
111
+
112
+ def test_z_cmod
113
+ assert_equal(GMP::Z, @a.cmod(@b).class, "GMP::Z.cmod GMP::Z should be GMP::Z.")
114
+ assert_equal(GMP::Z, @a.cmod(3).class, "GMP::Z.cmod Fixnum should be GMP::Z.")
115
+ assert_equal(GMP::Z, @a.cmod(2**32).class, "GMP::Z.cmod Bignum should be GMP::Z.")
116
+ assert_equal(GMP::Z, @a.cmod(@c).class, "GMP::Z.cmod GMP::Z should be GMP::Z.")
117
+ assert_equal( -2, @a.cmod(@b), "GMP::Z.cmod should work.")
118
+ assert_equal( -3, @b.cmod(@a), "GMP::Z.cmod should work.")
119
+ assert_equal( -1, @a.cmod( 3), "GMP::Z.cmod should work.")
120
+ assert_equal(-20, @a.cmod(@c), "GMP::Z.cmod should work.")
121
+ assert_equal( 0, @c.cmod(@a), "GMP::Z.cmod should work.")
122
+ end
99
123
  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.8
4
+ version: 0.1.9
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-20 00:00:00 -07:00
13
+ date: 2009-11-23 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
 
@@ -58,6 +58,7 @@ files:
58
58
  - CHANGELOG
59
59
  - INSTALL
60
60
  - README.rdoc
61
+ - manual.pdf
61
62
  - manual.tex
62
63
  has_rdoc: false
63
64
  homepage: http://github.com/srawlins/gmp