Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / man / man3 / Math::BigInt::Calc.3
CommitLineData
86530b38
AT
1.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
2.\"
3.\" Standard preamble:
4.\" ========================================================================
5.de Sh \" Subsection heading
6.br
7.if t .Sp
8.ne 5
9.PP
10\fB\\$1\fR
11.PP
12..
13.de Sp \" Vertical space (when we can't use .PP)
14.if t .sp .5v
15.if n .sp
16..
17.de Vb \" Begin verbatim text
18.ft CW
19.nf
20.ne \\$1
21..
22.de Ve \" End verbatim text
23.ft R
24.fi
25..
26.\" Set up some character translations and predefined strings. \*(-- will
27.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28.\" double quote, and \*(R" will give a right double quote. | will give a
29.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31.\" expand to `' in nroff, nothing in troff, for use with C<>.
32.tr \(*W-|\(bv\*(Tr
33.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34.ie n \{\
35. ds -- \(*W-
36. ds PI pi
37. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39. ds L" ""
40. ds R" ""
41. ds C` ""
42. ds C' ""
43'br\}
44.el\{\
45. ds -- \|\(em\|
46. ds PI \(*p
47. ds L" ``
48. ds R" ''
49'br\}
50.\"
51.\" If the F register is turned on, we'll generate index entries on stderr for
52.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53.\" entries marked with X<> in POD. Of course, you'll have to process the
54.\" output yourself in some meaningful fashion.
55.if \nF \{\
56. de IX
57. tm Index:\\$1\t\\n%\t"\\$2"
58..
59. nr % 0
60. rr F
61.\}
62.\"
63.\" For nroff, turn off justification. Always turn off hyphenation; it makes
64.\" way too many mistakes in technical documents.
65.hy 0
66.if n .na
67.\"
68.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69.\" Fear. Run. Save yourself. No user-serviceable parts.
70. \" fudge factors for nroff and troff
71.if n \{\
72. ds #H 0
73. ds #V .8m
74. ds #F .3m
75. ds #[ \f1
76. ds #] \fP
77.\}
78.if t \{\
79. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80. ds #V .6m
81. ds #F 0
82. ds #[ \&
83. ds #] \&
84.\}
85. \" simple accents for nroff and troff
86.if n \{\
87. ds ' \&
88. ds ` \&
89. ds ^ \&
90. ds , \&
91. ds ~ ~
92. ds /
93.\}
94.if t \{\
95. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101.\}
102. \" troff and (daisy-wheel) nroff accents
103.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110.ds ae a\h'-(\w'a'u*4/10)'e
111.ds Ae A\h'-(\w'A'u*4/10)'E
112. \" corrections for vroff
113.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115. \" for low resolution devices (crt and lpr)
116.if \n(.H>23 .if \n(.V>19 \
117\{\
118. ds : e
119. ds 8 ss
120. ds o a
121. ds d- d\h'-1'\(ga
122. ds D- D\h'-1'\(hy
123. ds th \o'bp'
124. ds Th \o'LP'
125. ds ae ae
126. ds Ae AE
127.\}
128.rm #[ #] #H #V #F C
129.\" ========================================================================
130.\"
131.IX Title "Math::BigInt::Calc 3"
132.TH Math::BigInt::Calc 3 "2002-06-01" "perl v5.8.0" "Perl Programmers Reference Guide"
133.SH "NAME"
134Math::BigInt::Calc \- Pure Perl module to support Math::BigInt
135.SH "SYNOPSIS"
136.IX Header "SYNOPSIS"
137Provides support for big integer calculations. Not intended to be used by other
138modules (except Math::BigInt::Cached). Other modules which sport the same
139functions can also be used to support Math::Bigint, like Math::BigInt::Pari.
140.SH "DESCRIPTION"
141.IX Header "DESCRIPTION"
142In order to allow for multiple big integer libraries, Math::BigInt was
143rewritten to use library modules for core math routines. Any module which
144follows the same \s-1API\s0 as this can be used instead by using the following:
145.PP
146.Vb 1
147\& use Math::BigInt lib => 'libname';
148.Ve
149.PP
150\&'libname' is either the long name ('Math::BigInt::Pari'), or only the short
151version like 'Pari'.
152.SH "EXPORT"
153.IX Header "EXPORT"
154The following functions \s-1MUST\s0 be defined in order to support the use by
155Math::BigInt:
156.PP
157.Vb 3
158\& _new(string) return ref to new object from ref to decimal string
159\& _zero() return a new object with value 0
160\& _one() return a new object with value 1
161.Ve
162.PP
163.Vb 5
164\& _str(obj) return ref to a string representing the object
165\& _num(obj) returns a Perl integer/floating point number
166\& NOTE: because of Perl numeric notation defaults,
167\& the _num'ified obj may lose accuracy due to
168\& machine-dependend floating point size limitations
169.Ve
170.PP
171.Vb 13
172\& _add(obj,obj) Simple addition of two objects
173\& _mul(obj,obj) Multiplication of two objects
174\& _div(obj,obj) Division of the 1st object by the 2nd
175\& In list context, returns (result,remainder).
176\& NOTE: this is integer math, so no
177\& fractional part will be returned.
178\& _sub(obj,obj) Simple subtraction of 1 object from another
179\& a third, optional parameter indicates that the params
180\& are swapped. In this case, the first param needs to
181\& be preserved, while you can destroy the second.
182\& sub (x,y,1) => return x - y and keep x intact!
183\& _dec(obj) decrement object by one (input is garant. to be > 0)
184\& _inc(obj) increment object by one
185.Ve
186.PP
187.Vb 1
188\& _acmp(obj,obj) <=> operator for objects (return -1, 0 or 1)
189.Ve
190.PP
191.Vb 2
192\& _len(obj) returns count of the decimal digits of the object
193\& _digit(obj,n) returns the n'th decimal digit of object
194.Ve
195.PP
196.Vb 4
197\& _is_one(obj) return true if argument is +1
198\& _is_zero(obj) return true if argument is 0
199\& _is_even(obj) return true if argument is even (0,2,4,6..)
200\& _is_odd(obj) return true if argument is odd (1,3,5,7..)
201.Ve
202.PP
203.Vb 1
204\& _copy return a ref to a true copy of the object
205.Ve
206.PP
207.Vb 2
208\& _check(obj) check whether internal representation is still intact
209\& return 0 for ok, otherwise error message as string
210.Ve
211.PP
212The following functions are optional, and can be defined if the underlying lib
213has a fast way to do them. If undefined, Math::BigInt will use pure Perl (hence
214slow) fallback routines to emulate these:
215.PP
216.Vb 2
217\& _from_hex(str) return ref to new object from ref to hexadecimal string
218\& _from_bin(str) return ref to new object from ref to binary string
219.Ve
220.PP
221.Vb 6
222\& _as_hex(str) return ref to scalar string containing the value as
223\& unsigned hex string, with the '0x' prepended.
224\& Leading zeros must be stripped.
225\& _as_bin(str) Like as_hex, only as binary string containing only
226\& zeros and ones. Leading zeros must be stripped and a
227\& '0b' must be prepended.
228.Ve
229.PP
230.Vb 4
231\& _rsft(obj,N,B) shift object in base B by N 'digits' right
232\& For unsupported bases B, return undef to signal failure
233\& _lsft(obj,N,B) shift object in base B by N 'digits' left
234\& For unsupported bases B, return undef to signal failure
235.Ve
236.PP
237.Vb 4
238\& _xor(obj1,obj2) XOR (bit-wise) object 1 with object 2
239\& Note: XOR, AND and OR pad with zeros if size mismatches
240\& _and(obj1,obj2) AND (bit-wise) object 1 with object 2
241\& _or(obj1,obj2) OR (bit-wise) object 1 with object 2
242.Ve
243.PP
244.Vb 5
245\& _mod(obj,obj) Return remainder of div of the 1st by the 2nd object
246\& _sqrt(obj) return the square root of object (truncate to int)
247\& _fac(obj) return factorial of object 1 (1*2*3*4..)
248\& _pow(obj,obj) return object 1 to the power of object 2
249\& _gcd(obj,obj) return Greatest Common Divisor of two objects
250.Ve
251.PP
252.Vb 3
253\& _zeros(obj) return number of trailing decimal zeros
254\& _modinv return inverse modulus
255\& _modpow return modulus of power ($x ** $y) % $z
256.Ve
257.PP
258Input strings come in as unsigned but with prefix (i.e. as '123', '0xabc'
259or '0b1101').
260.PP
261Testing of input parameter validity is done by the caller, so you need not
262worry about underflow (f.i. in \f(CW\*(C`_sub()\*(C'\fR, \f(CW\*(C`_dec()\*(C'\fR) nor about division by
263zero or similar cases.
264.PP
265The first parameter can be modified, that includes the possibility that you
266return a reference to a completely different object instead. Although keeping
267the reference and just changing it's contents is prefered over creating and
268returning a different reference.
269.PP
270Return values are always references to objects or strings. Exceptions are
271\&\f(CW\*(C`_lsft()\*(C'\fR and \f(CW\*(C`_rsft()\*(C'\fR, which return undef if they can not shift the
272argument. This is used to delegate shifting of bases different than the one
273you can support back to Math::BigInt, which will use some generic code to
274calculate the result.
275.SH "WRAP YOUR OWN"
276.IX Header "WRAP YOUR OWN"
277If you want to port your own favourite c\-lib for big numbers to the
278Math::BigInt interface, you can take any of the already existing modules as
279a rough guideline. You should really wrap up the latest BigInt and BigFloat
280testsuites with your module, and replace in them any of the following:
281.PP
282.Vb 1
283\& use Math::BigInt;
284.Ve
285.PP
286by this:
287.PP
288.Vb 1
289\& use Math::BigInt lib => 'yourlib';
290.Ve
291.PP
292This way you ensure that your library really works 100% within Math::BigInt.
293.SH "LICENSE"
294.IX Header "LICENSE"
295This program is free software; you may redistribute it and/or modify it under
296the same terms as Perl itself.
297.SH "AUTHORS"
298.IX Header "AUTHORS"
299Original math code by Mark Biggar, rewritten by Tels <http://bloodgate.com/>
300in late 2000, 2001.
301Seperated from BigInt and shaped \s-1API\s0 with the help of John Peacock.
302.SH "SEE ALSO"
303.IX Header "SEE ALSO"
304Math::BigInt, Math::BigFloat, Math::BigInt::BitVect,
305Math::BigInt::GMP, Math::BigInt::Cached and Math::BigInt::Pari.