blob: a6490b982a3ae84b945ad3b709d1c5fe66c2c6e6 [file] [log] [blame]
Stefan Krah1919b7e2012-03-21 18:25:23 +01001/*
2 * Copyright (c) 2001-2012 Python Software Foundation. All Rights Reserved.
3 * Modified and extended by Stefan Krah.
4 */
5
6
7#ifndef DOCSTRINGS_H
8#define DOCSTRINGS_H
9
10
11#include "pymacro.h"
12
13
14/******************************************************************************/
15/* Module */
16/******************************************************************************/
17
18
19PyDoc_STRVAR(doc__decimal,
20"C decimal arithmetic module");
21
22PyDoc_STRVAR(doc_getcontext,"\n\
23getcontext() - Get the current default context.\n\
24\n");
25
26PyDoc_STRVAR(doc_setcontext,"\n\
27setcontext(c) - Set a new default context.\n\
28\n");
29
30PyDoc_STRVAR(doc_localcontext,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +010031localcontext(ctx=None) - Return a context manager that will set the default\n\
32context to a copy of ctx on entry to the with-statement and restore the\n\
33previous default context when exiting the with-statement. If no context is\n\
34specified, a copy of the current default context is used.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +010035\n");
36
37#ifdef EXTRA_FUNCTIONALITY
38PyDoc_STRVAR(doc_ieee_context,"\n\
39IEEEContext(bits) - Return a context object initialized to the proper values for\n\
40one of the IEEE interchange formats. The argument must be a multiple of 32 and\n\
41less than IEEE_CONTEXT_MAX_BITS. For the most common values, the constants\n\
42DECIMAL32, DECIMAL64 and DECIMAL128 are provided.\n\
43\n");
44#endif
45
46
47/******************************************************************************/
48/* Decimal Object and Methods */
49/******************************************************************************/
50
51PyDoc_STRVAR(doc_decimal,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +010052Decimal(value=\"0\", context=None): Construct a new Decimal object.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +010053value can be an integer, string, tuple, or another Decimal object.\n\
54If no value is given, return Decimal('0'). The context does not affect\n\
55the conversion and is only passed to determine if the InvalidOperation\n\
56trap is active.\n\
57\n");
58
59PyDoc_STRVAR(doc_adjusted,"\n\
60adjusted() - Return the adjusted exponent of the number.\n\
61\n\
62Defined as exp + digits - 1.\n\
63\n");
64
65PyDoc_STRVAR(doc_as_tuple,"\n\
66as_tuple() - Return a tuple representation of the number.\n\
67\n");
68
69PyDoc_STRVAR(doc_canonical,"\n\
70canonical() - Return the canonical encoding of the argument. Currently,\n\
71the encoding of a Decimal instance is always canonical, so this operation\n\
72returns its argument unchanged.\n\
73\n");
74
75PyDoc_STRVAR(doc_compare,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +010076compare(other, context=None) - Compare self to other. Return a decimal value:\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +010077\n\
78 a or b is a NaN ==> Decimal('NaN')\n\
79 a < b ==> Decimal('-1')\n\
80 a == b ==> Decimal('0')\n\
81 a > b ==> Decimal('1')\n\
82\n");
83
84PyDoc_STRVAR(doc_compare_signal,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +010085compare_signal(other, context=None) - Identical to compare, except that\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +010086all NaNs signal.\n\
87\n");
88
89PyDoc_STRVAR(doc_compare_total,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +010090compare_total(other, context=None) - Compare two operands using their\n\
91abstract representation rather than their numerical value. Similar to the\n\
92compare() method, but the result gives a total ordering on Decimal instances.\n\
93Two Decimal instances with the same numeric value but different representations\n\
94compare unequal in this ordering:\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +010095\n\
96 >>> Decimal('12.0').compare_total(Decimal('12'))\n\
97 Decimal('-1')\n\
98\n\
99Quiet and signaling NaNs are also included in the total ordering. The result\n\
100of this function is Decimal('0') if both operands have the same representation,\n\
101Decimal('-1') if the first operand is lower in the total order than the second,\n\
102and Decimal('1') if the first operand is higher in the total order than the\n\
103second operand. See the specification for details of the total order.\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100104\n\
105This operation is unaffected by context and is quiet: no flags are changed\n\
106and no rounding is performed. As an exception, the C version may raise\n\
107InvalidOperation if the second operand cannot be converted exactly.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100108\n");
109
110PyDoc_STRVAR(doc_compare_total_mag,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100111compare_total_mag(other, context=None) - Compare two operands using their\n\
112abstract representation rather than their value as in compare_total(), but\n\
113ignoring the sign of each operand. x.compare_total_mag(y) is equivalent to\n\
114x.copy_abs().compare_total(y.copy_abs()).\n\
115\n\
116This operation is unaffected by context and is quiet: no flags are changed\n\
117and no rounding is performed. As an exception, the C version may raise\n\
118InvalidOperation if the second operand cannot be converted exactly.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100119\n");
120
121PyDoc_STRVAR(doc_conjugate,"\n\
122conjugate() - Return self.\n\
123\n");
124
125PyDoc_STRVAR(doc_copy_abs,"\n\
126copy_abs() - Return the absolute value of the argument. This operation\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100127is unaffected by context and is quiet: no flags are changed and no rounding\n\
128is performed.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100129\n");
130
131PyDoc_STRVAR(doc_copy_negate,"\n\
132copy_negate() - Return the negation of the argument. This operation is\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100133unaffected by context and is quiet: no flags are changed and no rounding\n\
134is performed.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100135\n");
136
137PyDoc_STRVAR(doc_copy_sign,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100138copy_sign(other, context=None) - Return a copy of the first operand with\n\
139the sign set to be the same as the sign of the second operand. For example:\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100140\n\
141 >>> Decimal('2.3').copy_sign(Decimal('-1.5'))\n\
142 Decimal('-2.3')\n\
143\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100144This operation is unaffected by context and is quiet: no flags are changed\n\
145and no rounding is performed. As an exception, the C version may raise\n\
146InvalidOperation if the second operand cannot be converted exactly.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100147\n");
148
149PyDoc_STRVAR(doc_exp,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100150exp(context=None) - Return the value of the (natural) exponential function\n\
151e**x at the given number. The function always uses the ROUND_HALF_EVEN mode\n\
152and the result is correctly rounded.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100153\n");
154
155PyDoc_STRVAR(doc_from_float,"\n\
156from_float(f) - Class method that converts a float to a decimal number, exactly.\n\
157Since 0.1 is not exactly representable in binary floating point,\n\
158Decimal.from_float(0.1) is not the same as Decimal('0.1').\n\
159\n\
160 >>> Decimal.from_float(0.1)\n\
161 Decimal('0.1000000000000000055511151231257827021181583404541015625')\n\
162 >>> Decimal.from_float(float('nan'))\n\
163 Decimal('NaN')\n\
164 >>> Decimal.from_float(float('inf'))\n\
165 Decimal('Infinity')\n\
166 >>> Decimal.from_float(float('-inf'))\n\
167 Decimal('-Infinity')\n\
168\n\
169\n");
170
171PyDoc_STRVAR(doc_fma,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100172fma(other, third, context=None) - Fused multiply-add. Return self*other+third\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100173with no rounding of the intermediate product self*other.\n\
174\n\
175 >>> Decimal(2).fma(3, 5)\n\
176 Decimal('11')\n\
177\n\
178\n");
179
180PyDoc_STRVAR(doc_is_canonical,"\n\
181is_canonical() - Return True if the argument is canonical and False otherwise.\n\
182Currently, a Decimal instance is always canonical, so this operation always\n\
183returns True.\n\
184\n");
185
186PyDoc_STRVAR(doc_is_finite,"\n\
187is_finite() - Return True if the argument is a finite number, and False if the\n\
188argument is infinite or a NaN.\n\
189\n");
190
191PyDoc_STRVAR(doc_is_infinite,"\n\
192is_infinite() - Return True if the argument is either positive or negative\n\
193infinity and False otherwise.\n\
194\n");
195
196PyDoc_STRVAR(doc_is_nan,"\n\
197is_nan() - Return True if the argument is a (quiet or signaling) NaN and\n\
198False otherwise.\n\
199\n");
200
201PyDoc_STRVAR(doc_is_normal,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100202is_normal(context=None) - Return True if the argument is a normal finite\n\
203non-zero number with an adjusted exponent greater than or equal to Emin.\n\
204Return False if the argument is zero, subnormal, infinite or a NaN.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100205\n");
206
207PyDoc_STRVAR(doc_is_qnan,"\n\
208is_qnan() - Return True if the argument is a quiet NaN, and False otherwise.\n\
209\n");
210
211PyDoc_STRVAR(doc_is_signed,"\n\
212is_signed() - Return True if the argument has a negative sign and\n\
213False otherwise. Note that both zeros and NaNs can carry signs.\n\
214\n");
215
216PyDoc_STRVAR(doc_is_snan,"\n\
217is_snan() - Return True if the argument is a signaling NaN and False otherwise.\n\
218\n");
219
220PyDoc_STRVAR(doc_is_subnormal,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100221is_subnormal(context=None) - Return True if the argument is subnormal, and\n\
222False otherwise. A number is subnormal if it is non-zero, finite, and has an\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100223adjusted exponent less than Emin.\n\
224\n");
225
226PyDoc_STRVAR(doc_is_zero,"\n\
227is_zero() - Return True if the argument is a (positive or negative) zero and\n\
228False otherwise.\n\
229\n");
230
231PyDoc_STRVAR(doc_ln,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100232ln(context=None) - Return the natural (base e) logarithm of the operand.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100233The function always uses the ROUND_HALF_EVEN mode and the result is\n\
234correctly rounded.\n\
235\n");
236
237PyDoc_STRVAR(doc_log10,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100238log10(context=None) - Return the base ten logarithm of the operand.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100239The function always uses the ROUND_HALF_EVEN mode and the result is\n\
240correctly rounded.\n\
241\n");
242
243PyDoc_STRVAR(doc_logb,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100244logb(context=None) - For a non-zero number, return the adjusted exponent\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100245of the operand as a Decimal instance. If the operand is a zero, then\n\
246Decimal('-Infinity') is returned and the DivisionByZero condition is\n\
247raised. If the operand is an infinity then Decimal('Infinity') is returned.\n\
248\n");
249
250PyDoc_STRVAR(doc_logical_and,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100251logical_and(other, context=None) - Return the digit-wise and of the two\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100252(logical) operands.\n\
253\n");
254
255PyDoc_STRVAR(doc_logical_invert,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100256logical_invert(context=None) - Return the digit-wise inversion of the\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100257(logical) operand.\n\
258\n");
259
260PyDoc_STRVAR(doc_logical_or,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100261logical_or(other, context=None) - Return the digit-wise or of the two\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100262(logical) operands.\n\
263\n");
264
265PyDoc_STRVAR(doc_logical_xor,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100266logical_xor(other, context=None) - Return the digit-wise exclusive or of the\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100267two (logical) operands.\n\
268\n");
269
270PyDoc_STRVAR(doc_max,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100271max(other, context=None) - Maximum of self and other. If one operand is a\n\
272quiet NaN and the other is numeric, the numeric operand is returned.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100273\n");
274
275PyDoc_STRVAR(doc_max_mag,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100276max_mag(other, context=None) - Similar to the max() method, but the\n\
277comparison is done using the absolute values of the operands.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100278\n");
279
280PyDoc_STRVAR(doc_min,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100281min(other, context=None) - Minimum of self and other. If one operand is a\n\
282quiet NaN and the other is numeric, the numeric operand is returned.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100283\n");
284
285PyDoc_STRVAR(doc_min_mag,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100286min_mag(other, context=None) - Similar to the min() method, but the\n\
287comparison is done using the absolute values of the operands.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100288\n");
289
290PyDoc_STRVAR(doc_next_minus,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100291next_minus(context=None) - Return the largest number representable in the\n\
292given context (or in the current default context if no context is given) that\n\
293is smaller than the given operand.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100294\n");
295
296PyDoc_STRVAR(doc_next_plus,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100297next_plus(context=None) - Return the smallest number representable in the\n\
298given context (or in the current default context if no context is given) that\n\
299is larger than the given operand.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100300\n");
301
302PyDoc_STRVAR(doc_next_toward,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100303next_toward(other, context=None) - If the two operands are unequal, return\n\
304the number closest to the first operand in the direction of the second operand.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100305If both operands are numerically equal, return a copy of the first operand\n\
306with the sign set to be the same as the sign of the second operand.\n\
307\n");
308
309PyDoc_STRVAR(doc_normalize,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100310normalize(context=None) - Normalize the number by stripping the rightmost\n\
311trailing zeros and converting any result equal to Decimal('0') to Decimal('0e0').\n\
312Used for producing canonical values for members of an equivalence class. For\n\
313example, Decimal('32.100') and Decimal('0.321000e+2') both normalize to the\n\
314equivalent value Decimal('32.1').\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100315\n");
316
317PyDoc_STRVAR(doc_number_class,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100318number_class(context=None) - Return a string describing the class of the\n\
319operand. The returned value is one of the following ten strings:\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100320\n\
321 * '-Infinity', indicating that the operand is negative infinity.\n\
322 * '-Normal', indicating that the operand is a negative normal number.\n\
323 * '-Subnormal', indicating that the operand is negative and subnormal.\n\
324 * '-Zero', indicating that the operand is a negative zero.\n\
325 * '+Zero', indicating that the operand is a positive zero.\n\
326 * '+Subnormal', indicating that the operand is positive and subnormal.\n\
327 * '+Normal', indicating that the operand is a positive normal number.\n\
328 * '+Infinity', indicating that the operand is positive infinity.\n\
329 * 'NaN', indicating that the operand is a quiet NaN (Not a Number).\n\
330 * 'sNaN', indicating that the operand is a signaling NaN.\n\
331\n\
332\n");
333
334PyDoc_STRVAR(doc_quantize,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100335quantize(exp, rounding=None, context=None) - Return a value equal to the\n\
336first operand after rounding and having the exponent of the second operand.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100337\n\
338 >>> Decimal('1.41421356').quantize(Decimal('1.000'))\n\
339 Decimal('1.414')\n\
340\n\
341Unlike other operations, if the length of the coefficient after the quantize\n\
342operation would be greater than precision, then an InvalidOperation is signaled.\n\
343This guarantees that, unless there is an error condition, the quantized exponent\n\
344is always equal to that of the right-hand operand.\n\
345\n\
346Also unlike other operations, quantize never signals Underflow, even if the\n\
347result is subnormal and inexact.\n\
348\n\
349If the exponent of the second operand is larger than that of the first, then\n\
350rounding may be necessary. In this case, the rounding mode is determined by the\n\
351rounding argument if given, else by the given context argument; if neither\n\
352argument is given, the rounding mode of the current thread's context is used.\n\
353\n");
354
355PyDoc_STRVAR(doc_radix,"\n\
356radix() - Return Decimal(10), the radix (base) in which the Decimal class does\n\
357all its arithmetic. Included for compatibility with the specification.\n\
358\n");
359
360PyDoc_STRVAR(doc_remainder_near,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100361remainder_near(other, context=None) - Return the remainder from dividing\n\
362self by other. This differs from self % other in that the sign of the\n\
363remainder is chosen so as to minimize its absolute value. More precisely, the\n\
364return value is self - n * other where n is the integer nearest to the exact\n\
365value of self / other, and if two integers are equally near then the even one\n\
366is chosen.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100367\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100368If the result is zero then its sign will be the sign of self.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100369\n");
370
371PyDoc_STRVAR(doc_rotate,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100372rotate(other, context=None) - Return the result of rotating the digits of the\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100373first operand by an amount specified by the second operand. The second operand\n\
374must be an integer in the range -precision through precision. The absolute\n\
375value of the second operand gives the number of places to rotate. If the second\n\
376operand is positive then rotation is to the left; otherwise rotation is to the\n\
377right. The coefficient of the first operand is padded on the left with zeros to\n\
378length precision if necessary. The sign and exponent of the first operand are\n\
379unchanged.\n\
380\n");
381
382PyDoc_STRVAR(doc_same_quantum,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100383same_quantum(other, context=None) - Test whether self and other have the\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100384same exponent or whether both are NaN.\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100385\n\
386This operation is unaffected by context and is quiet: no flags are changed\n\
387and no rounding is performed. As an exception, the C version may raise\n\
388InvalidOperation if the second operand cannot be converted exactly.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100389\n");
390
391PyDoc_STRVAR(doc_scaleb,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100392scaleb(other, context=None) - Return the first operand with the exponent\n\
393adjusted the second. Equivalently, return the first operand multiplied by\n\
39410**other. The second operand must be an integer.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100395\n");
396
397PyDoc_STRVAR(doc_shift,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100398shift(other, context=None) - Return the result of shifting the digits of\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100399the first operand by an amount specified by the second operand. The second\n\
400operand must be an integer in the range -precision through precision. The\n\
401absolute value of the second operand gives the number of places to shift.\n\
402If the second operand is positive, then the shift is to the left; otherwise\n\
403the shift is to the right. Digits shifted into the coefficient are zeros.\n\
404The sign and exponent of the first operand are unchanged.\n\
405\n");
406
407PyDoc_STRVAR(doc_sqrt,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100408sqrt(context=None) - Return the square root of the argument to full precision.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100409The result is correctly rounded using the ROUND_HALF_EVEN rounding mode.\n\
410\n");
411
412PyDoc_STRVAR(doc_to_eng_string,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100413to_eng_string(context=None) - Convert to an engineering-type string.\n\
414Engineering notation has an exponent which is a multiple of 3, so there\n\
415are up to 3 digits left of the decimal place. For example, Decimal('123E+1')\n\
416is converted to Decimal('1.23E+3').\n\
417\n\
418The value of context.capitals determines whether the exponent sign is lower\n\
419or upper case. Otherwise, the context does not affect the operation.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100420\n");
421
422PyDoc_STRVAR(doc_to_integral,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100423to_integral(rounding=None, context=None) - Identical to the\n\
424to_integral_value() method. The to_integral() name has been kept\n\
425for compatibility with older versions.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100426\n");
427
428PyDoc_STRVAR(doc_to_integral_exact,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100429to_integral_exact(rounding=None, context=None) - Round to the nearest\n\
430integer, signaling Inexact or Rounded as appropriate if rounding occurs.\n\
431The rounding mode is determined by the rounding parameter if given, else\n\
432by the given context. If neither parameter is given, then the rounding mode\n\
433of the current default context is used.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100434\n");
435
436PyDoc_STRVAR(doc_to_integral_value,"\n\
Stefan Krah040e3112012-12-15 22:33:33 +0100437to_integral_value(rounding=None, context=None) - Round to the nearest\n\
438integer without signaling Inexact or Rounded. The rounding mode is determined\n\
439by the rounding parameter if given, else by the given context. If neither\n\
440parameter is given, then the rounding mode of the current default context is\n\
441used.\n\
Stefan Krah1919b7e2012-03-21 18:25:23 +0100442\n");
443
444
445/******************************************************************************/
446/* Context Object and Methods */
447/******************************************************************************/
448
449PyDoc_STRVAR(doc_context,"\n\
450The context affects almost all operations and controls rounding,\n\
451Over/Underflow, raising of exceptions and much more. A new context\n\
452can be constructed as follows:\n\
453\n\
454 >>> c = Context(prec=28, Emin=-425000000, Emax=425000000,\n\
455 ... rounding=ROUND_HALF_EVEN, capitals=1, clamp=1,\n\
456 ... traps=[InvalidOperation, DivisionByZero, Overflow],\n\
457 ... flags=[])\n\
458 >>>\n\
459\n\
460\n");
461
462#ifdef EXTRA_FUNCTIONALITY
463PyDoc_STRVAR(doc_ctx_apply,"\n\
464apply(x) - Apply self to Decimal x.\n\
465\n");
466#endif
467
468PyDoc_STRVAR(doc_ctx_clear_flags,"\n\
469clear_flags() - Reset all flags to False.\n\
470\n");
471
472PyDoc_STRVAR(doc_ctx_clear_traps,"\n\
473clear_traps() - Set all traps to False.\n\
474\n");
475
476PyDoc_STRVAR(doc_ctx_copy,"\n\
477copy() - Return a duplicate of the context with all flags cleared.\n\
478\n");
479
480PyDoc_STRVAR(doc_ctx_copy_decimal,"\n\
481copy_decimal(x) - Return a copy of Decimal x.\n\
482\n");
483
484PyDoc_STRVAR(doc_ctx_create_decimal,"\n\
485create_decimal(x) - Create a new Decimal instance from x, using self as the\n\
486context. Unlike the Decimal constructor, this function observes the context\n\
487limits.\n\
488\n");
489
490PyDoc_STRVAR(doc_ctx_create_decimal_from_float,"\n\
491create_decimal_from_float(f) - Create a new Decimal instance from float f.\n\
492Unlike the Decimal.from_float() class method, this function observes the\n\
493context limits.\n\
494\n");
495
496PyDoc_STRVAR(doc_ctx_Etiny,"\n\
497Etiny() - Return a value equal to Emin - prec + 1, which is the minimum\n\
498exponent value for subnormal results. When underflow occurs, the exponent\n\
499is set to Etiny.\n\
500\n");
501
502PyDoc_STRVAR(doc_ctx_Etop,"\n\
503Etop() - Return a value equal to Emax - prec + 1. This is the maximum exponent\n\
504if the _clamp field of the context is set to 1 (IEEE clamp mode). Etop() must\n\
505not be negative.\n\
506\n");
507
508PyDoc_STRVAR(doc_ctx_abs,"\n\
509abs(x) - Return the absolute value of x.\n\
510\n");
511
512PyDoc_STRVAR(doc_ctx_add,"\n\
513add(x, y) - Return the sum of x and y.\n\
514\n");
515
516PyDoc_STRVAR(doc_ctx_canonical,"\n\
517canonical(x) - Return a new instance of x.\n\
518\n");
519
520PyDoc_STRVAR(doc_ctx_compare,"\n\
521compare(x, y) - Compare x and y numerically.\n\
522\n");
523
524PyDoc_STRVAR(doc_ctx_compare_signal,"\n\
525compare_signal(x, y) - Compare x and y numerically. All NaNs signal.\n\
526\n");
527
528PyDoc_STRVAR(doc_ctx_compare_total,"\n\
529compare_total(x, y) - Compare x and y using their abstract representation.\n\
530\n");
531
532PyDoc_STRVAR(doc_ctx_compare_total_mag,"\n\
533compare_total_mag(x, y) - Compare x and y using their abstract representation,\n\
534ignoring sign.\n\
535\n");
536
537PyDoc_STRVAR(doc_ctx_copy_abs,"\n\
538copy_abs(x) - Return a copy of x with the sign set to 0.\n\
539\n");
540
541PyDoc_STRVAR(doc_ctx_copy_negate,"\n\
542copy_negate(x) - Return a copy of x with the sign inverted.\n\
543\n");
544
545PyDoc_STRVAR(doc_ctx_copy_sign,"\n\
546copy_sign(x, y) - Copy the sign from y to x.\n\
547\n");
548
549PyDoc_STRVAR(doc_ctx_divide,"\n\
550divide(x, y) - Return x divided by y.\n\
551\n");
552
553PyDoc_STRVAR(doc_ctx_divide_int,"\n\
554divide_int(x, y) - Return x divided by y, truncated to an integer.\n\
555\n");
556
557PyDoc_STRVAR(doc_ctx_divmod,"\n\
558divmod(x, y) - Return quotient and remainder of the division x / y.\n\
559\n");
560
561PyDoc_STRVAR(doc_ctx_exp,"\n\
562exp(x) - Return e ** x.\n\
563\n");
564
565PyDoc_STRVAR(doc_ctx_fma,"\n\
566fma(x, y, z) - Return x multiplied by y, plus z.\n\
567\n");
568
569PyDoc_STRVAR(doc_ctx_is_canonical,"\n\
570is_canonical(x) - Return True if x is canonical, False otherwise.\n\
571\n");
572
573PyDoc_STRVAR(doc_ctx_is_finite,"\n\
574is_finite(x) - Return True if x is finite, False otherwise.\n\
575\n");
576
577PyDoc_STRVAR(doc_ctx_is_infinite,"\n\
578is_infinite(x) - Return True if x is infinite, False otherwise.\n\
579\n");
580
581PyDoc_STRVAR(doc_ctx_is_nan,"\n\
582is_nan(x) - Return True if x is a qNaN or sNaN, False otherwise.\n\
583\n");
584
585PyDoc_STRVAR(doc_ctx_is_normal,"\n\
586is_normal(x) - Return True if x is a normal number, False otherwise.\n\
587\n");
588
589PyDoc_STRVAR(doc_ctx_is_qnan,"\n\
590is_qnan(x) - Return True if x is a quiet NaN, False otherwise.\n\
591\n");
592
593PyDoc_STRVAR(doc_ctx_is_signed,"\n\
594is_signed(x) - Return True if x is negative, False otherwise.\n\
595\n");
596
597PyDoc_STRVAR(doc_ctx_is_snan,"\n\
598is_snan() - Return True if x is a signaling NaN, False otherwise.\n\
599\n");
600
601PyDoc_STRVAR(doc_ctx_is_subnormal,"\n\
602is_subnormal(x) - Return True if x is subnormal, False otherwise.\n\
603\n");
604
605PyDoc_STRVAR(doc_ctx_is_zero,"\n\
606is_zero(x) - Return True if x is a zero, False otherwise.\n\
607\n");
608
609PyDoc_STRVAR(doc_ctx_ln,"\n\
610ln(x) - Return the natural (base e) logarithm of x.\n\
611\n");
612
613PyDoc_STRVAR(doc_ctx_log10,"\n\
614log10(x) - Return the base 10 logarithm of x.\n\
615\n");
616
617PyDoc_STRVAR(doc_ctx_logb,"\n\
618logb(x) - Return the exponent of the magnitude of the operand's MSD.\n\
619\n");
620
621PyDoc_STRVAR(doc_ctx_logical_and,"\n\
622logical_and(x, y) - Digit-wise and of x and y.\n\
623\n");
624
625PyDoc_STRVAR(doc_ctx_logical_invert,"\n\
626logical_invert(x) - Invert all digits of x.\n\
627\n");
628
629PyDoc_STRVAR(doc_ctx_logical_or,"\n\
630logical_or(x, y) - Digit-wise or of x and y.\n\
631\n");
632
633PyDoc_STRVAR(doc_ctx_logical_xor,"\n\
634logical_xor(x, y) - Digit-wise xor of x and y.\n\
635\n");
636
637PyDoc_STRVAR(doc_ctx_max,"\n\
638max(x, y) - Compare the values numerically and return the maximum.\n\
639\n");
640
641PyDoc_STRVAR(doc_ctx_max_mag,"\n\
642max_mag(x, y) - Compare the values numerically with their sign ignored.\n\
643\n");
644
645PyDoc_STRVAR(doc_ctx_min,"\n\
646min(x, y) - Compare the values numerically and return the minimum.\n\
647\n");
648
649PyDoc_STRVAR(doc_ctx_min_mag,"\n\
650min_mag(x, y) - Compare the values numerically with their sign ignored.\n\
651\n");
652
653PyDoc_STRVAR(doc_ctx_minus,"\n\
654minus(x) - Minus corresponds to the unary prefix minus operator in Python,\n\
655but applies the context to the result.\n\
656\n");
657
658PyDoc_STRVAR(doc_ctx_multiply,"\n\
659multiply(x, y) - Return the product of x and y.\n\
660\n");
661
662PyDoc_STRVAR(doc_ctx_next_minus,"\n\
663next_minus(x) - Return the largest representable number smaller than x.\n\
664\n");
665
666PyDoc_STRVAR(doc_ctx_next_plus,"\n\
667next_plus(x) - Return the smallest representable number larger than x.\n\
668\n");
669
670PyDoc_STRVAR(doc_ctx_next_toward,"\n\
671next_toward(x) - Return the number closest to x, in the direction towards y.\n\
672\n");
673
674PyDoc_STRVAR(doc_ctx_normalize,"\n\
675normalize(x) - Reduce x to its simplest form. Alias for reduce(x).\n\
676\n");
677
678PyDoc_STRVAR(doc_ctx_number_class,"\n\
679number_class(x) - Return an indication of the class of x.\n\
680\n");
681
682PyDoc_STRVAR(doc_ctx_plus,"\n\
683plus(x) - Plus corresponds to the unary prefix plus operator in Python,\n\
684but applies the context to the result.\n\
685\n");
686
687PyDoc_STRVAR(doc_ctx_power,"\n\
688power(x, y) - Compute x**y. If x is negative, then y must be integral.\n\
689The result will be inexact unless y is integral and the result is finite\n\
690and can be expressed exactly in 'precision' digits. In the Python version\n\
691the result is always correctly rounded, in the C version the result is\n\
692almost always correctly rounded.\n\
693\n\
694power(x, y, m) - Compute (x**y) % m. The following restrictions hold:\n\
695\n\
696 * all three arguments must be integral\n\
697 * y must be nonnegative\n\
698 * at least one of x or y must be nonzero\n\
699 * m must be nonzero and less than 10**prec in absolute value\n\
700\n\
701\n");
702
703PyDoc_STRVAR(doc_ctx_quantize,"\n\
704quantize(x, y) - Return a value equal to x (rounded), having the exponent of y.\n\
705\n");
706
707PyDoc_STRVAR(doc_ctx_radix,"\n\
708radix() - Return 10.\n\
709\n");
710
711PyDoc_STRVAR(doc_ctx_remainder,"\n\
712remainder(x, y) - Return the remainder from integer division. The sign of\n\
713the result, if non-zero, is the same as that of the original dividend.\n\
714\n");
715
716PyDoc_STRVAR(doc_ctx_remainder_near,"\n\
717remainder_near(x, y) - Return x - y * n, where n is the integer nearest the\n\
718exact value of x / y (if the result is 0 then its sign will be the sign of x).\n\
719\n");
720
721PyDoc_STRVAR(doc_ctx_rotate,"\n\
722rotate(x, y) - Return a copy of x, rotated by y places.\n\
723\n");
724
725PyDoc_STRVAR(doc_ctx_same_quantum,"\n\
726same_quantum(x, y) - Return True if the two operands have the same exponent.\n\
727\n");
728
729PyDoc_STRVAR(doc_ctx_scaleb,"\n\
730scaleb(x, y) - Return the first operand after adding the second value\n\
731to its exp.\n\
732\n");
733
734PyDoc_STRVAR(doc_ctx_shift,"\n\
735shift(x, y) - Return a copy of x, shifted by y places.\n\
736\n");
737
738PyDoc_STRVAR(doc_ctx_sqrt,"\n\
739sqrt(x) - Square root of a non-negative number to context precision.\n\
740\n");
741
742PyDoc_STRVAR(doc_ctx_subtract,"\n\
743subtract(x, y) - Return the difference between x and y.\n\
744\n");
745
746PyDoc_STRVAR(doc_ctx_to_eng_string,"\n\
747to_eng_string(x) - Convert a number to a string, using engineering notation.\n\
748\n");
749
750PyDoc_STRVAR(doc_ctx_to_integral,"\n\
751to_integral(x) - Identical to to_integral_value(x).\n\
752\n");
753
754PyDoc_STRVAR(doc_ctx_to_integral_exact,"\n\
755to_integral_exact(x) - Round to an integer. Signal if the result is\n\
756rounded or inexact.\n\
757\n");
758
759PyDoc_STRVAR(doc_ctx_to_integral_value,"\n\
760to_integral_value(x) - Round to an integer.\n\
761\n");
762
763PyDoc_STRVAR(doc_ctx_to_sci_string,"\n\
764to_sci_string(x) - Convert a number to a string using scientific notation.\n\
765\n");
766
767
768#endif /* DOCSTRINGS_H */
769
770
771