Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(65)

Delta Between Two Patch Sets: Modules/_decimal/docstrings.h

Issue 27779: Sync-up docstrings in C version of the the decimal module
Left Patch Set: Created 3 years, 4 months ago
Right Patch Set: Created 3 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Lib/_pydecimal.py ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * Copyright (c) 2001-2012 Python Software Foundation. All Rights Reserved. 2 * Copyright (c) 2001-2012 Python Software Foundation. All Rights Reserved.
3 * Modified and extended by Stefan Krah. 3 * Modified and extended by Stefan Krah.
4 */ 4 */
5 5
6 6
7 #ifndef DOCSTRINGS_H 7 #ifndef DOCSTRINGS_H
8 #define DOCSTRINGS_H 8 #define DOCSTRINGS_H
9 9
10 10
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 \n"); 125 \n");
126 126
127 /*This seems clearer than the python version*/ 127 /*This seems clearer than the python version*/
128 PyDoc_STRVAR(doc_setcontext, 128 PyDoc_STRVAR(doc_setcontext,
129 "setcontext($module, context, /)\n--\n\n\ 129 "setcontext($module, context, /)\n--\n\n\
130 Set a new default context.\n\ 130 Set a new default context.\n\
131 \n"); 131 \n");
132 132
133 PyDoc_STRVAR(doc_localcontext, 133 PyDoc_STRVAR(doc_localcontext,
134 "localcontext($module, /, ctx=None)\n--\n\n\ 134 "localcontext($module, /, ctx=None)\n--\n\n\
135 Return a context manager for a copy of the supplied context.\n\ 135 Return a context manager that will set the default context to a copy of ctx\n\
136 Uses a copy of the current context if no context is specified.\n\ 136 on entry to the with-statement and restore the previous default context when\n\
137 exiting the with-statement. If no context is specified, a copy of the current\n\
138 default context is used.\n\
137 The returned context manager creates a local decimal context\n\ 139 The returned context manager creates a local decimal context\n\
138 in a with statement:\n\ 140 in a with statement:\n\
139 def sin(x):\n\ 141 def sin(x):\n\
140 with localcontext() as ctx:\n\ 142 with localcontext() as ctx:\n\
141 ctx.prec += 2\n\ 143 ctx.prec += 2\n\
142 # Rest of sin calculation algorithm\n\ 144 # Rest of sin calculation algorithm\n\
143 # uses a precision 2 greater than normal\n\ 145 # uses a precision 2 greater than normal\n\
144 return +s # Convert result to normal precision\n\ 146 return +s # Convert result to normal precision\n\
145 \n\ 147 \n\
146 def sin(x):\n\ 148 def sin(x):\n\
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 Decimal('3.14')\n\ 236 Decimal('3.14')\n\
235 \n"); 237 \n");
236 238
237 PyDoc_STRVAR(doc_adjusted, 239 PyDoc_STRVAR(doc_adjusted,
238 "adjusted($self, /)\n--\n\n\ 240 "adjusted($self, /)\n--\n\n\
239 Return the adjusted exponent of the number. Defined as exp + digits - 1.\n\ 241 Return the adjusted exponent of the number. Defined as exp + digits - 1.\n\
240 \n"); 242 \n");
241 243
242 PyDoc_STRVAR(doc_as_tuple, 244 PyDoc_STRVAR(doc_as_tuple,
243 "as_tuple($self, /)\n--\n\n\ 245 "as_tuple($self, /)\n--\n\n\
244 Represents the number as a triple tuple, to show the internals exactly as\n\ 246 Represents the number as a triple tuple, to show the internals exactly as\n\
skrah 2016/10/23 21:39:46 This is outdated for the Python version and wrong
lisroach 2016/12/01 22:44:42 For python 3.7 it looks correct to me?
skrah 2017/04/06 18:58:35 I meant "show the internals exactly as they are".
245 they are.\n\ 247 they are.\n\
246 \n"); 248 \n");
247 249
248 PyDoc_STRVAR(doc_as_integer_ratio, 250 PyDoc_STRVAR(doc_as_integer_ratio,
249 "as_integer_ratio($self, /)\n--\n\n\ 251 "as_integer_ratio($self, /)\n--\n\n\
250 Express a finite Decimal instance in the form n / d.\n\ 252 Express a finite Decimal instance in the form n / d.\n\
251 Return a pair (n, d) of integers, whose ratio is exactly equal to the original\n \ 253 Return a pair (n, d) of integers, whose ratio is exactly equal to the original\n \
252 Decimal and with a positive denominator. The ratio is in lowest terms.\n\ 254 Decimal and with a positive denominator. The ratio is in lowest terms.\n\
253 Raise OverflowError on infinities and a ValueError on NaNs.\n\ 255 Raise OverflowError on infinities and a ValueError on NaNs.\n\
254 \n\ 256 \n\
(...skipping 10 matching lines...) Expand all
265 Returns the same Decimal object.\n\ 267 Returns the same Decimal object.\n\
266 As we do not have different encodings for the same number, the received\n\ 268 As we do not have different encodings for the same number, the received\n\
267 object already is in its canonical form.\n\ 269 object already is in its canonical form.\n\
268 \n\ 270 \n\
269 >>> ExtendedContext.canonical(Decimal('2.50'))\n\ 271 >>> ExtendedContext.canonical(Decimal('2.50'))\n\
270 Decimal('2.50')\n\ 272 Decimal('2.50')\n\
271 \n"); 273 \n");
272 274
273 PyDoc_STRVAR(doc_compare, 275 PyDoc_STRVAR(doc_compare,
274 "compare($self, /, other, context=None)\n--\n\n\ 276 "compare($self, /, other, context=None)\n--\n\n\
275 Compares values numerically.\n\ 277 Compare values numerically.\n\
276 \n\ 278 \n\
277 If the signs of the operands differ, a value representing each operand\n\ 279 If the signs of the operands differ, a value representing each operand\n\
278 ('-1' if the operand is less than zero, '0' if the operand is zero or\n\ 280 ('-1' if the operand is less than zero, '0' if the operand is zero or\n\
279 negative zero, or '1' if the operand is greater than zero) is used in\n\ 281 negative zero, or '1' if the operand is greater than zero) is used in\n\
280 place of that operand for the comparison instead of the actual\n\ 282 place of that operand for the comparison instead of the actual\n\
281 operand.\n\ 283 operand.\n\
282 \n\ 284 \n\
283 The comparison is then effected by subtracting the second operand from\n\ 285 The comparison is then effected by subtracting the second operand from\n\
284 the first and then returning a value according to the result of the\n\ 286 the first and then returning a value according to the result of the\n\
285 subtraction: '-1' if the result is less than zero, '0' if the result is\n\ 287 subtraction: '-1' if the result is less than zero, '0' if the result is\n\
(...skipping 21 matching lines...) Expand all
307 >>> ExtendedContext.compare(Decimal(1), 2)\n\ 309 >>> ExtendedContext.compare(Decimal(1), 2)\n\
308 Decimal('-1')\n\ 310 Decimal('-1')\n\
309 >>> ExtendedContext.compare(1, Decimal(2))\n\ 311 >>> ExtendedContext.compare(1, Decimal(2))\n\
310 Decimal('-1')\n\ 312 Decimal('-1')\n\
311 >>> ExtendedContext.compare(Decimal('2'), Decimal('NaN'))\n\ 313 >>> ExtendedContext.compare(Decimal('2'), Decimal('NaN'))\n\
312 Decimal('NaN')\n\ 314 Decimal('NaN')\n\
313 \n"); 315 \n");
314 316
315 PyDoc_STRVAR(doc_compare_signal, 317 PyDoc_STRVAR(doc_compare_signal,
316 "compare_signal($self, /, other, context=None)\n--\n\n\ 318 "compare_signal($self, /, other, context=None)\n--\n\n\
317 Compares the values of the two operands numerically.\n\ 319 Compare the values of the two operands numerically.\n\
318 \n\ 320 \n\
319 It's pretty much like compare(), but all NaNs signal, with signaling\n\ 321 It's pretty much like compare(), but all NaNs signal, with signaling\n\
320 NaNs taking precedence over quiet NaNs.\n\ 322 NaNs taking precedence over quiet NaNs.\n\
321 \n\ 323 \n\
322 >>> c = ExtendedContext\n\ 324 >>> ExtendedContext.compare_signal(Decimal('2.1'), Decimal('3'))\n\
323 >>> c.compare_signal(Decimal('2.1'), Decimal('3'))\n\ 325 Decimal('-1')\n\
324 Decimal('-1')\n\ 326 >>> ExtendedContext.compare_signal(Decimal('2.1'), Decimal('2.1'))\n\
325 >>> c.compare_signal(Decimal('2.1'), Decimal('2.1'))\n\ 327 Decimal('0')\n\
326 Decimal('0')\n\ 328 >>> ExtendedContext.flags[InvalidOperation] = 0\n\
327 >>> c.flags[InvalidOperation] = 0\n\ 329 >>> print(ExtendedContext.flags[InvalidOperation])\n\
328 >>> print(c.flags[InvalidOperation])\n\
329 0\n\ 330 0\n\
330 >>> c.compare_signal(Decimal('NaN'), Decimal('2.1'))\n\ 331 >>> ExtendedContext.compare_signal(Decimal('NaN'), Decimal('2.1'))\n\
331 Decimal('NaN')\n\ 332 Decimal('NaN')\n\
332 >>> print(c.flags[InvalidOperation])\n\ 333 >>> print(ExtendedContext.flags[InvalidOperation])\n\
333 1\n\ 334 1\n\
334 >>> c.flags[InvalidOperation] = 0\n\ 335 >>> ExtendedContext.flags[InvalidOperation] = 0\n\
335 >>> print(c.flags[InvalidOperation])\n\ 336 >>> print(ExtendedContext.flags[InvalidOperation])\n\
336 0\n\ 337 0\n\
337 >>> c.compare_signal(Decimal('sNaN'), Decimal('2.1'))\n\ 338 >>> ExtendedContext.compare_signal(Decimal('sNaN'), Decimal('2.1'))\n\
338 Decimal('NaN')\n\ 339 Decimal('NaN')\n\
339 >>> print(c.flags[InvalidOperation])\n\ 340 >>> print(ExtendedContext.flags[InvalidOperation])\n\
340 1\n\ 341 1\n\
341 >>> c.compare_signal(-1, 2)\n\ 342 >>> ExtendedContext.compare_signal(-1, 2)\n\
342 Decimal('-1')\n\ 343 Decimal('-1')\n\
343 >>> c.compare_signal(Decimal(-1), 2)\n\ 344 >>> ExtendedContext.compare_signal(Decimal(-1), 2)\n\
344 Decimal('-1')\n\ 345 Decimal('-1')\n\
345 >>> c.compare_signal(-1, Decimal(2))\n\ 346 >>> ExtendedContext.compare_signal(-1, Decimal(2))\n\
346 Decimal('-1')\n\ 347 Decimal('-1')\n\
347 \n"); 348 \n");
348 349
349 PyDoc_STRVAR(doc_compare_total, 350 PyDoc_STRVAR(doc_compare_total,
350 "compare_total($self, /, other, context=None)\n--\n\n\ 351 "compare_total($self, /, other, context=None)\n--\n\n\
351 Compares two operands using their abstract representation rather than\n\ 352 Compare two operands using their abstract representation rather than\n\
skrah 2016/10/23 21:39:46 Everyone has a preferred form. I think Guido prefe
lisroach 2016/12/01 22:44:42 Done.
352 their numerical value. Similar to the compare() method, but the result\n\ 353 their numerical value. Similar to the compare() method, but the result\n\
353 gives a total ordering on Decimal instances.\n\ 354 gives a total ordering on Decimal instances. Two Decimal instances with\n\
355 the same numeric value but different representations compare unequal\n\
356 in this ordering:\n\
357 \n\
358 >>> Decimal('12.0').compare_total(Decimal('12'))\n\
359 Decimal('-1')\n\
354 \n\ 360 \n\
355 Quiet and signaling NaNs are also included in the total ordering. The result\n\ 361 Quiet and signaling NaNs are also included in the total ordering. The result\n\
356 of this function is Decimal('0') if both operands have the same representation,\ n\ 362 of this function is Decimal('0') if both operands have the same representation,\ n\
357 Decimal('-1') if the first operand is lower in the total order than the second,\ n\ 363 Decimal('-1') if the first operand is lower in the total order than the second,\ n\
358 and Decimal('1') if the first operand is higher in the total order than the\n\ 364 and Decimal('1') if the first operand is higher in the total order than the\n\
359 second operand. See the specification for details of the total order.\n\ 365 second operand. See the specification for details of the total order.\n\
360 \n\ 366 \n\
361 This operation is unaffected by context and is quiet: no flags are changed\n\ 367 This operation is unaffected by context and is quiet: no flags are changed\n\
362 and no rounding is performed. As an exception, the C version may raise\n\ 368 and no rounding is performed. As an exception, the C version may raise\n\
363 InvalidOperation if the second operand cannot be converted exactly.\n\ 369 InvalidOperation if the second operand cannot be converted exactly.\n\
(...skipping 13 matching lines...) Expand all
377 >>> ExtendedContext.compare_total(1, 2)\n\ 383 >>> ExtendedContext.compare_total(1, 2)\n\
378 Decimal('-1')\n\ 384 Decimal('-1')\n\
379 >>> ExtendedContext.compare_total(Decimal(1), 2)\n\ 385 >>> ExtendedContext.compare_total(Decimal(1), 2)\n\
380 Decimal('-1')\n\ 386 Decimal('-1')\n\
381 >>> ExtendedContext.compare_total(1, Decimal(2))\n\ 387 >>> ExtendedContext.compare_total(1, Decimal(2))\n\
382 Decimal('-1')\n\ 388 Decimal('-1')\n\
383 \n"); 389 \n");
384 390
385 PyDoc_STRVAR(doc_compare_total_mag, 391 PyDoc_STRVAR(doc_compare_total_mag,
386 "compare_total_mag($self, /, other, context=None)\n--\n\n\ 392 "compare_total_mag($self, /, other, context=None)\n--\n\n\
387 Compares two operands using their abstract representation rather than their\n\ 393 Compare two operands using their abstract representation rather than their\n\
388 numerical value and with their sign ignored. Like compare_total, but with\n\ 394 numerical value and with their sign ignored. Like compare_total, but with\n\
389 operand's sign ignored and assumed to be 0.\n\ 395 operand's sign ignored and assumed to be 0.\n\
390 \n\ 396 \n\
391 x.compare_total_mag(y) is equivalent to x.copy_abs().compare_total(y.copy_abs()) .\n\ 397 x.compare_total_mag(y) is equivalent to x.copy_abs().compare_total(y.copy_abs()) .\n\
392 \n\ 398 \n\
393 This operation is unaffected by context and is quiet: no flags are changed\n\ 399 This operation is unaffected by context and is quiet: no flags are changed\n\
394 and no rounding is performed. As an exception, the C version may raise\n\ 400 and no rounding is performed. As an exception, the C version may raise\n\
395 InvalidOperation if the second operand cannot be converted exactly.\n\ 401 InvalidOperation if the second operand cannot be converted exactly.\n\
396 \n"); 402 \n");
397 403
398 PyDoc_STRVAR(doc_conjugate, 404 PyDoc_STRVAR(doc_conjugate,
399 "conjugate($self, /)\n--\n\n\ 405 "conjugate($self, /)\n--\n\n\
400 Returns self.\n\ 406 Returns self.\n\
401 \n"); 407 \n");
402 408
403 PyDoc_STRVAR(doc_copy_abs, 409 PyDoc_STRVAR(doc_copy_abs,
404 "copy_abs($self, /)\n--\n\n\ 410 "copy_abs($self, /)\n--\n\n\
405 Returns a copy of the operand with the sign set to 0. This operation is unaffect ed by\n\ 411 Returns the absolute value of the argument. This operation is unaffected by\n\
skrah 2016/10/23 21:59:26 I think "sign set to zero" is a bit confusing for
lisroach 2016/12/01 22:44:42 Done.
lisroach 2016/12/01 22:44:42 Done.
406 context and is quiet: no flags are changed and no rounding is performed.\n\ 412 context and is quiet: no flags are changed and no rounding is performed.\n\
407 \n\ 413 \n\
408 >>> ExtendedContext.copy_abs(Decimal('2.1'))\n\ 414 >>> ExtendedContext.copy_abs(Decimal('2.1'))\n\
409 Decimal('2.1')\n\ 415 Decimal('2.1')\n\
410 >>> ExtendedContext.copy_abs(Decimal('-100'))\n\ 416 >>> ExtendedContext.copy_abs(Decimal('-100'))\n\
411 Decimal('100')\n\ 417 Decimal('100')\n\
412 >>> ExtendedContext.copy_abs(-1)\n\ 418 >>> ExtendedContext.copy_abs(-1)\n\
413 Decimal('1')\n\ 419 Decimal('1')\n\
414 \n"); 420 \n");
415 421
416 PyDoc_STRVAR(doc_copy_negate, 422 PyDoc_STRVAR(doc_copy_negate,
417 "copy_negate($self, /)\n--\n\n\ 423 "copy_negate($self, /)\n--\n\n\
418 Returns a copy of the operand with the sign inverted. This operation is\n\ 424 Returns a copy of the operand with the sign inverted. This operation is\n\
419 unaffected by context and is quiet: no flags are changed and no rounding\n\ 425 unaffected by context and is quiet: no flags are changed and no rounding\n\
420 is performed.\n\ 426 is performed.\n\
421 \n\ 427 \n\
422 >>> ExtendedContext.copy_negate(Decimal('101.5'))\n\ 428 >>> ExtendedContext.copy_negate(Decimal('101.5'))\n\
423 Decimal('-101.5')\n\ 429 Decimal('-101.5')\n\
424 >>> ExtendedContext.copy_negate(Decimal('-101.5'))\n\ 430 >>> ExtendedContext.copy_negate(Decimal('-101.5'))\n\
425 Decimal('101.5')\n\ 431 Decimal('101.5')\n\
426 >>> ExtendedContext.copy_negate(1)\n\ 432 >>> ExtendedContext.copy_negate(1)\n\
427 Decimal('-1')\n\ 433 Decimal('-1')\n\
428 \n"); 434 \n");
429 435
430 PyDoc_STRVAR(doc_copy_sign, 436 PyDoc_STRVAR(doc_copy_sign,
431 "copy_sign($self, /, other, context=None)\n--\n\n\ 437 "copy_sign($self, /, other, context=None)\n--\n\n\
432 Copies the second operand's sign to the first one.\n\ 438 Returns a copy of the first operand with the sign equal to the second operand.\n \
skrah 2016/10/23 21:39:46 That sounds as if it is a destructive update.
lisroach 2016/12/01 22:44:42 Done.
433 In detail, it returns a copy of the first operand with the sign\n\
434 equal to the sign of the second operand.\n\
435 \n\ 439 \n\
436 >>> ExtendedContext.copy_sign(Decimal( '1.50'), Decimal('7.33'))\n\ 440 >>> ExtendedContext.copy_sign(Decimal( '1.50'), Decimal('7.33'))\n\
437 Decimal('1.50')\n\ 441 Decimal('1.50')\n\
438 >>> ExtendedContext.copy_sign(Decimal('-1.50'), Decimal('7.33'))\n\ 442 >>> ExtendedContext.copy_sign(Decimal('-1.50'), Decimal('7.33'))\n\
439 Decimal('1.50')\n\ 443 Decimal('1.50')\n\
440 >>> ExtendedContext.copy_sign(Decimal( '1.50'), Decimal('-7.33'))\n\ 444 >>> ExtendedContext.copy_sign(Decimal( '1.50'), Decimal('-7.33'))\n\
441 Decimal('-1.50')\n\ 445 Decimal('-1.50')\n\
442 >>> ExtendedContext.copy_sign(Decimal('-1.50'), Decimal('-7.33'))\n\ 446 >>> ExtendedContext.copy_sign(Decimal('-1.50'), Decimal('-7.33'))\n\
443 Decimal('-1.50')\n\ 447 Decimal('-1.50')\n\
444 >>> ExtendedContext.copy_sign(1, -2)\n\ 448 >>> ExtendedContext.copy_sign(1, -2)\n\
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 >>> c.log10(1)\n\ 733 >>> c.log10(1)\n\
730 Decimal('0')\n\ 734 Decimal('0')\n\
731 \n"); 735 \n");
732 736
733 PyDoc_STRVAR(doc_logb, 737 PyDoc_STRVAR(doc_logb,
734 "logb($self, /, context=None)\n--\n\n\ 738 "logb($self, /, context=None)\n--\n\n\
735 Returns the exponent of the magnitude of the operand's MSD.\n\ 739 Returns the exponent of the magnitude of the operand's MSD.\n\
736 The result is the integer which is the exponent of the magnitude\n\ 740 The result is the integer which is the exponent of the magnitude\n\
737 of the most significant digit of the operand (as though the\n\ 741 of the most significant digit of the operand (as though the\n\
738 operand were truncated to a single digit while maintaining the\n\ 742 operand were truncated to a single digit while maintaining the\n\
739 value of that digit and without limiting the resulting exponent).\n\ 743 value of that digit and without limiting the resulting exponent).\n\
skrah 2016/10/23 21:39:46 Personally, I have a hard time understanding this
lisroach 2016/12/01 22:44:42 I agree this is confusing. It is taken directly fr
740 \n\ 744 \n\
741 >>> ExtendedContext.logb(Decimal('250'))\n\ 745 >>> ExtendedContext.logb(Decimal('250'))\n\
742 Decimal('2')\n\ 746 Decimal('2')\n\
743 >>> ExtendedContext.logb(Decimal('2.50'))\n\ 747 >>> ExtendedContext.logb(Decimal('2.50'))\n\
744 Decimal('0')\n\ 748 Decimal('0')\n\
745 >>> ExtendedContext.logb(Decimal('0.03'))\n\ 749 >>> ExtendedContext.logb(Decimal('0.03'))\n\
746 Decimal('-2')\n\ 750 Decimal('-2')\n\
747 >>> ExtendedContext.logb(Decimal('0'))\n\ 751 >>> ExtendedContext.logb(Decimal('0'))\n\
748 Decimal('-Infinity')\n\ 752 Decimal('-Infinity')\n\
749 >>> ExtendedContext.logb(1)\n\ 753 >>> ExtendedContext.logb(1)\n\
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 >>> ExtendedContext.logical_invert(Decimal('111111111'))\n\ 795 >>> ExtendedContext.logical_invert(Decimal('111111111'))\n\
792 Decimal('0')\n\ 796 Decimal('0')\n\
793 >>> ExtendedContext.logical_invert(Decimal('101010101'))\n\ 797 >>> ExtendedContext.logical_invert(Decimal('101010101'))\n\
794 Decimal('10101010')\n\ 798 Decimal('10101010')\n\
795 >>> ExtendedContext.logical_invert(1101)\n\ 799 >>> ExtendedContext.logical_invert(1101)\n\
796 Decimal('111110010')\n\ 800 Decimal('111110010')\n\
797 \n"); 801 \n");
798 802
799 PyDoc_STRVAR(doc_logical_or, 803 PyDoc_STRVAR(doc_logical_or,
800 "logical_or($self, /, other, context=None)\n--\n\n\ 804 "logical_or($self, /, other, context=None)\n--\n\n\
801 Return the digit-wise 'or' of the two (logical) operands.\n\ 805 Applies the logical operation 'or' between each operand's digits.\n\
806 The operands must be both logical numbers.\n\
807 \n\
808 >>> ExtendedContext.logical_or(Decimal('0'), Decimal('0'))\n\
809 Decimal('0')\n\
810 >>> ExtendedContext.logical_or(Decimal('0'), Decimal('1'))\n\
811 Decimal('1')\n\
812 >>> ExtendedContext.logical_or(Decimal('1'), Decimal('0'))\n\
813 Decimal('1')\n\
814 >>> ExtendedContext.logical_or(Decimal('1'), Decimal('1'))\n\
815 Decimal('1')\n\
816 >>> ExtendedContext.logical_or(Decimal('1100'), Decimal('1010'))\n\
817 Decimal('1110')\n\
818 >>> ExtendedContext.logical_or(Decimal('1110'), Decimal('10'))\n\
819 Decimal('1110')\n\
820 >>> ExtendedContext.logical_or(110, 1101)\n\
821 Decimal('1111')\n\
822 >>> ExtendedContext.logical_or(Decimal(110), 1101)\n\
823 Decimal('1111')\n\
824 >>> ExtendedContext.logical_or(110, Decimal(1101))\n\
825 Decimal('1111')\n\
802 \n"); 826 \n");
803 827
804 PyDoc_STRVAR(doc_logical_xor, 828 PyDoc_STRVAR(doc_logical_xor,
805 "logical_xor($self, /, other, context=None)\n--\n\n\ 829 "logical_xor($self, /, other, context=None)\n--\n\n\
806 Return the digit-wise 'exclusive or' of the two (logical) operands.\n\ 830 Applies the logical operation 'xor' between each operand's digits.\n\
831 The operands must be both logical numbers.\n\
832 \n\
833 >>> ExtendedContext.logical_xor(Decimal('0'), Decimal('0'))\n\
834 Decimal('0')\n\
835 >>> ExtendedContext.logical_xor(Decimal('0'), Decimal('1'))\n\
836 Decimal('1')\n\
837 >>> ExtendedContext.logical_xor(Decimal('1'), Decimal('0'))\n\
838 Decimal('1')\n\
839 >>> ExtendedContext.logical_xor(Decimal('1'), Decimal('1'))\n\
840 Decimal('0')\n\
841 >>> ExtendedContext.logical_xor(Decimal('1100'), Decimal('1010'))\n\
842 Decimal('110')\n\
843 >>> ExtendedContext.logical_xor(Decimal('1111'), Decimal('10'))\n\
844 Decimal('1101')\n\
845 >>> ExtendedContext.logical_xor(110, 1101)\n\
846 Decimal('1011')\n\
847 >>> ExtendedContext.logical_xor(Decimal(110), 1101)\n\
848 Decimal('1011')\n\
849 >>> ExtendedContext.logical_xor(110, Decimal(1101))\n\
850 Decimal('1011')\n\
807 \n"); 851 \n");
808 852
809 PyDoc_STRVAR(doc_max, 853 PyDoc_STRVAR(doc_max,
810 "max($self, /, other, context=None)\n--\n\n\ 854 "max($self, /, other, context=None)\n--\n\n\
811 Maximum of self and other. If one operand is a quiet NaN and the other is\n\ 855 max compares two values numerically and returns the maximum.\n\
812 numeric, the numeric operand is returned.\n\ 856 \n\
857 If either operand is a NaN then the general rules apply.\n\
858 Otherwise, the operands are compared as though by the compare\n\
859 operation. If they are numerically equal then the left-hand operand\n\
860 is chosen as the result. Otherwise the maximum (closer to positive\n\
861 infinity) of the two operands is chosen as the result.\n\
862 \n\
863 >>> ExtendedContext.max(Decimal('3'), Decimal('2'))\n\
864 Decimal('3')\n\
865 >>> ExtendedContext.max(Decimal('-10'), Decimal('3'))\n\
866 Decimal('3')\n\
867 >>> ExtendedContext.max(Decimal('1.0'), Decimal('1'))\n\
868 Decimal('1')\n\
869 >>> ExtendedContext.max(Decimal('7'), Decimal('NaN'))\n\
870 Decimal('7')\n\
871 >>> ExtendedContext.max(1, 2)\n\
872 Decimal('2')\n\
873 >>> ExtendedContext.max(Decimal(1), 2)\n\
874 Decimal('2')\n\
875 >>> ExtendedContext.max(1, Decimal(2))\n\
876 Decimal('2')\n\
813 \n"); 877 \n");
814 878
815 PyDoc_STRVAR(doc_max_mag, 879 PyDoc_STRVAR(doc_max_mag,
816 "max_mag($self, /, other, context=None)\n--\n\n\ 880 "max_mag($self, /, other, context=None)\n--\n\n\
817 Similar to the max() method, but the comparison is done using the absolute\n\ 881 Compare the values numerically with their sign ignored.\n\
818 values of the operands.\n\ 882 \n\
883 >>> ExtendedContext.max_mag(Decimal('7'), Decimal('NaN'))\n\
884 Decimal('7')\n\
885 >>> ExtendedContext.max_mag(Decimal('7'), Decimal('-10'))
886 Decimal('-10')\n\
887 >>> ExtendedContext.max_mag(1, -2)\n\
888 Decimal('-2')\n\
889 >>> ExtendedContext.max_mag(Decimal(1), -2)\n\
890 Decimal('-2')\n\
891 >>> ExtendedContext.max_mag(1, Decimal(-2))\n\
892 Decimal('-2')\n\
819 \n"); 893 \n");
820 894
821 PyDoc_STRVAR(doc_min, 895 PyDoc_STRVAR(doc_min,
822 "min($self, /, other, context=None)\n--\n\n\ 896 "min($self, /, other, context=None)\n--\n\n\
823 Minimum of self and other. If one operand is a quiet NaN and the other is\n\ 897 min compares two values numerically and returns the minimum.\n\
824 numeric, the numeric operand is returned.\n\ 898 \n\
899 If either operand is a NaN then the general rules apply.\n\
900 Otherwise, the operands are compared as though by the compare\n\
901 operation. If they are numerically equal then the left-hand operand\n\
902 is chosen as the result. Otherwise the minimum (closer to negative\n\
903 infinity) of the two operands is chosen as the result.\n\
904 \n\
905 >>> ExtendedContext.min(Decimal('3'), Decimal('2'))\n\
906 Decimal('2')\n\
907 >>> ExtendedContext.min(Decimal('-10'), Decimal('3'))\n\
908 Decimal('-10')\n\
909 >>> ExtendedContext.min(Decimal('1.0'), Decimal('1'))\n\
910 Decimal('1.0')\n\
911 >>> ExtendedContext.min(Decimal('7'), Decimal('NaN'))\n\
912 Decimal('7')\n\
913 >>> ExtendedContext.min(1, 2)\n\
914 Decimal('1')\n\
915 >>> ExtendedContext.min(Decimal(1), 2)\n\
916 Decimal('1')\n\
917 >>> ExtendedContext.min(1, Decimal(29))\n\
918 Decimal('1')\n\
825 \n"); 919 \n");
826 920
827 PyDoc_STRVAR(doc_min_mag, 921 PyDoc_STRVAR(doc_min_mag,
828 "min_mag($self, /, other, context=None)\n--\n\n\ 922 "min_mag($self, /, other, context=None)\n--\n\n\
829 Similar to the min() method, but the comparison is done using the absolute\n\ 923 Compare the values numerically with their sign ignored.\n\
830 values of the operands.\n\ 924 \n\
925 >>> ExtendedContext.min_mag(Decimal('3'), Decimal('-2'))\n\
926 Decimal('-2')\n\
927 >>> ExtendedContext.min_mag(Decimal('-3'), Decimal('NaN'))\n\
928 Decimal('-3')\n\
929 >>> ExtendedContext.min_mag(1, -2)\n\
930 Decimal('1')\n\
931 >>> ExtendedContext.min_mag(Decimal(1), -2)\n\
932 Decimal('1')\n\
933 >>> ExtendedContext.min_mag(1, Decimal(-2))\n\
934 Decimal('1')\n\
831 \n"); 935 \n");
832 936
833 PyDoc_STRVAR(doc_next_minus, 937 PyDoc_STRVAR(doc_next_minus,
834 "next_minus($self, /, context=None)\n--\n\n\ 938 "next_minus($self, /, context=None)\n--\n\n\
835 Return the largest number representable in the given context (or in the\n\ 939 Returns the largest representable number smaller than a.\n\
836 current default context if no context is given) that is smaller than the\n\ 940 \n\
837 given operand.\n\ 941 >>> c = ExtendedContext.copy()\n\
942 >>> c.Emin = -999\n\
943 >>> c.Emax = 999\n\
944 >>> ExtendedContext.next_minus(Decimal('1'))\n\
945 Decimal('0.999999999')\n\
946 >>> c.next_minus(Decimal('1E-1007'))\n\
947 Decimal('0E-1007')\n\
948 >>> ExtendedContext.next_minus(Decimal('-1.00000003'))\n\
949 Decimal('-1.00000004')\n\
950 >>> c.next_minus(Decimal('Infinity'))\n\
951 Decimal('9.99999999E+999')\n\
952 >>> c.next_minus(1)\n\
953 Decimal('0.999999999')\n\
838 \n"); 954 \n");
839 955
840 PyDoc_STRVAR(doc_next_plus, 956 PyDoc_STRVAR(doc_next_plus,
841 "next_plus($self, /, context=None)\n--\n\n\ 957 "next_plus($self, /, context=None)\n--\n\n\
842 Return the smallest number representable in the given context (or in the\n\ 958 Returns the smallest representable number larger than a.\n\
843 current default context if no context is given) that is larger than the\n\ 959 \n\
844 given operand.\n\ 960 >>> c = ExtendedContext.copy()\n\
961 >>> c.Emin = -999\n\
962 >>> c.Emax = 999\n\
963 >>> ExtendedContext.next_plus(Decimal('1'))\n\
964 Decimal('1.00000001')\n\
965 >>> c.next_plus(Decimal('-1E-1007'))\n\
966 Decimal('-0E-1007')\n\
967 >>> ExtendedContext.next_plus(Decimal('-1.00000003'))\n\
968 Decimal('-1.00000002')\n\
969 >>> c.next_plus(Decimal('-Infinity'))\n\
970 Decimal('-9.99999999E+999')\n\
971 >>> c.next_plus(1)\n\
972 Decimal('1.00000001')\n\
845 \n"); 973 \n");
846 974
847 PyDoc_STRVAR(doc_next_toward, 975 PyDoc_STRVAR(doc_next_toward,
848 "next_toward($self, /, other, context=None)\n--\n\n\ 976 "next_toward($self, /, other, context=None)\n--\n\n\
849 If the two operands are unequal, return the number closest to the first\n\ 977 Returns the number closest to a, in direction towards b.\n\
850 operand in the direction of the second operand. If both operands are\n\ 978 \n\
851 numerically equal, return a copy of the first operand with the sign set\n\ 979 The result is the closest representable number from the first\n\
852 to be the same as the sign of the second operand.\n\ 980 operand (but not the first operand) that is in the direction\n\
981 towards the second operand, unless the operands have the same\n\
982 value.\n\
983 \n\
984 >>> c = ExtendedContext.copy()\n\
985 >>> c.Emin = -999\n\
986 >>> c.Emax = 999\n\
987 >>> c.next_toward(Decimal('1'), Decimal('2'))\n\
988 Decimal('1.00000001')\n\
989 >>> c.next_toward(Decimal('-1E-1007'), Decimal('1'))\n\
990 Decimal('-0E-1007')\n\
991 >>> c.next_toward(Decimal('-1.00000003'), Decimal('0'))\n\
992 Decimal('-1.00000002')\n\
993 >>> c.next_toward(Decimal('1'), Decimal('0'))\n\
994 Decimal('0.999999999')\n\
995 >>> c.next_toward(Decimal('1E-1007'), Decimal('-100'))\n\
996 Decimal('0E-1007')\n\
997 >>> c.next_toward(Decimal('-1.00000003'), Decimal('-10'))\n\
998 Decimal('-1.00000004')\n\
999 >>> c.next_toward(Decimal('0.00'), Decimal('-0.0000'))\n\
1000 Decimal('-0.00')\n\
1001 >>> c.next_toward(0, 1)\n\
1002 Decimal('1E-1007')\n\
1003 >>> c.next_toward(Decimal(0), 1)\n\
1004 Decimal('1E-1007')\n\
1005 >>> c.next_toward(0, Decimal(1))\n\
1006 Decimal('1E-1007')\n\
853 \n"); 1007 \n");
854 1008
855 PyDoc_STRVAR(doc_normalize, 1009 PyDoc_STRVAR(doc_normalize,
856 "normalize($self, /, context=None)\n--\n\n\ 1010 "normalize($self, /, context=None)\n--\n\n\
857 Normalize the number by stripping the rightmost trailing zeros and\n\ 1011 normalize reduces an operand to its simplest form.\n\
858 converting any result equal to Decimal('0') to Decimal('0e0'). Used\n\ 1012 \n\
859 for producing canonical values for members of an equivalence class.\n\ 1013 Essentially a plus operation with all trailing zeros removed from the\n\
860 For example, Decimal('32.100') and Decimal('0.321000e+2') both normalize\n\ 1014 result.\n\
861 to the equivalent value Decimal('32.1').\n\ 1015 \n\
1016 >>> ExtendedContext.normalize(Decimal('2.1'))\n\
1017 Decimal('2.1')\n\
1018 >>> ExtendedContext.normalize(Decimal('-2.0'))\n\
1019 Decimal('-2')\n\
1020 >>> ExtendedContext.normalize(Decimal('1.200'))\n\
1021 Decimal('1.2')\n\
1022 >>> ExtendedContext.normalize(Decimal('-120'))\n\
1023 Decimal('-1.2E+2')\n\
1024 >>> ExtendedContext.normalize(Decimal('120.00'))\n\
1025 Decimal('1.2E+2')\n\
1026 >>> ExtendedContext.normalize(Decimal('0.00'))\n\
1027 Decimal('0')\n\
1028 >>> ExtendedContext.normalize(6)\n\
1029 Decimal('6')\n\
862 \n"); 1030 \n");
863 1031
864 PyDoc_STRVAR(doc_number_class, 1032 PyDoc_STRVAR(doc_number_class,
865 "number_class($self, /, context=None)\n--\n\n\ 1033 "number_class($self, /, context=None)\n--\n\n\
866 Return a string describing the class of the operand. The returned value\n\ 1034 Returns an indication of the class of the operand.\n\
867 is one of the following ten strings:\n\ 1035 \n\
1036 The class is one of the following strings:\n\
868 \n\ 1037 \n\
869 * '-Infinity', indicating that the operand is negative infinity.\n\ 1038 * '-Infinity', indicating that the operand is negative infinity.\n\
870 * '-Normal', indicating that the operand is a negative normal number.\n\ 1039 * '-Normal', indicating that the operand is a negative normal number.\n\
871 * '-Subnormal', indicating that the operand is negative and subnormal.\n\ 1040 * '-Subnormal', indicating that the operand is negative and subnormal.\n\
872 * '-Zero', indicating that the operand is a negative zero.\n\ 1041 * '-Zero', indicating that the operand is a negative zero.\n\
873 * '+Zero', indicating that the operand is a positive zero.\n\ 1042 * '+Zero', indicating that the operand is a positive zero.\n\
874 * '+Subnormal', indicating that the operand is positive and subnormal.\n\ 1043 * '+Subnormal', indicating that the operand is positive and subnormal.\n\
875 * '+Normal', indicating that the operand is a positive normal number.\n\ 1044 * '+Normal', indicating that the operand is a positive normal number.\n\
876 * '+Infinity', indicating that the operand is positive infinity.\n\ 1045 * '+Infinity', indicating that the operand is positive infinity.\n\
877 * 'NaN', indicating that the operand is a quiet NaN (Not a Number).\n\ 1046 * 'NaN', indicating that the operand is a quiet NaN (Not a Number).\n\
878 * 'sNaN', indicating that the operand is a signaling NaN.\n\ 1047 * 'sNaN', indicating that the operand is a signaling NaN.\n\
879 \n\ 1048 \n\
1049 >>> c = ExtendedContext.copy()\n\
1050 >>> c.Emin = -999\n\
1051 >>> c.Emax = 999\n\
1052 >>> c.number_class(Decimal('Infinity'))\n\
1053 '+Infinity'\n\
1054 >>> c.number_class(Decimal('1E-10'))\n\
1055 '+Normal'\n\
1056 >>> c.number_class(Decimal('2.50'))\n\
1057 '+Normal'\n\
1058 >>> c.number_class(Decimal('0.1E-999'))\n\
1059 '+Subnormal'\n\
1060 >>> c.number_class(Decimal('0'))\n\
1061 '+Zero'\n\
1062 >>> c.number_class(Decimal('-0'))\n\
1063 '-Zero'\n\
1064 >>> c.number_class(Decimal('-0.1E-999'))\n\
1065 '-Subnormal'\n\
1066 >>> c.number_class(Decimal('-1E-10'))\n\
1067 '-Normal'\n\
1068 >>> c.number_class(Decimal('-2.50'))\n\
1069 '-Normal'\n\
1070 >>> c.number_class(Decimal('-Infinity'))\n\
1071 '-Infinity'\n\
1072 >>> c.number_class(Decimal('NaN'))\n\
1073 'NaN'\n\
1074 >>> c.number_class(Decimal('-NaN'))\n\
1075 'NaN'\n\
1076 >>> c.number_class(Decimal('sNaN'))\n\
1077 'sNaN'\n\
1078 >>> c.number_class(123)\n\
1079 '+Normal'\n\
880 \n"); 1080 \n");
881 1081
882 PyDoc_STRVAR(doc_quantize, 1082 PyDoc_STRVAR(doc_quantize,
883 "quantize($self, /, exp, rounding=None, context=None)\n--\n\n\ 1083 "quantize($self, /, exp, rounding=None, context=None)\n--\n\n\
884 Return a value equal to the first operand after rounding and having the\n\ 1084 Returns a value equal to 'a' (rounded), having the exponent of 'b'.\n\
885 exponent of the second operand.\n\ 1085 \n\
886 \n\ 1086 The coefficient of the result is derived from that of the left-hand\n\
887 >>> Decimal('1.41421356').quantize(Decimal('1.000'))\n\ 1087 operand. It may be rounded using the current rounding setting (if the\n\
888 Decimal('1.414')\n\ 1088 exponent is being increased), multiplied by a positive power of ten (if\n\
889 \n\ 1089 the exponent is being decreased), or is unchanged (if the exponent is\n\
890 Unlike other operations, if the length of the coefficient after the quantize\n\ 1090 already equal to that of the right-hand operand).\n\
891 operation would be greater than precision, then an InvalidOperation is signaled. \n\ 1091 \n\
892 This guarantees that, unless there is an error condition, the quantized exponent \n\ 1092 Unlike other operations, if the length of the coefficient after the\n\
893 is always equal to that of the right-hand operand.\n\ 1093 quantize operation would be greater than precision then an Invalid\n\
894 \n\ 1094 operation condition is raised. This guarantees that, unless there is\n\
895 Also unlike other operations, quantize never signals Underflow, even if the\n\ 1095 an error condition, the exponent of the result of a quantize is always\n\
896 result is subnormal and inexact.\n\ 1096 equal to that of the right-hand operand.\n\
897 \n\ 1097 Also unlike other operations, quantize will never raise Underflow, even\n\
898 If the exponent of the second operand is larger than that of the first, then\n\ 1098 if the result is subnormal and inexact.\n\
899 rounding may be necessary. In this case, the rounding mode is determined by the\ n\ 1099 \n\
900 rounding argument if given, else by the given context argument; if neither\n\ 1100 >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.001'))\n\
901 argument is given, the rounding mode of the current thread's context is used.\n\ 1101 Decimal('2.170')\n\
1102 >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.01'))\n\
1103 Decimal('2.17')\n\
1104 >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('0.1'))\n\
1105 Decimal('2.2')\n\
1106 >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('1e+0'))\n\
1107 Decimal('2')\n\
1108 >>> ExtendedContext.quantize(Decimal('2.17'), Decimal('1e+1'))\n\
1109 Decimal('0E+1')\n\
1110 >>> ExtendedContext.quantize(Decimal('-Inf'), Decimal('Infinity'))\n\
1111 Decimal('-Infinity')\n\
1112 >>> ExtendedContext.quantize(Decimal('2'), Decimal('Infinity'))\n\
1113 Decimal('NaN')\n\
1114 >>> ExtendedContext.quantize(Decimal('-0.1'), Decimal('1'))\n\
1115 Decimal('-0')\n\
1116 >>> ExtendedContext.quantize(Decimal('-0'), Decimal('1e+5'))\n\
1117 Decimal('-0E+5')\n\
1118 >>> ExtendedContext.quantize(Decimal('+35236450.6'), Decimal('1e-2'))\n\
1119 Decimal('NaN')\n\
1120 >>> ExtendedContext.quantize(Decimal('-35236450.6'), Decimal('1e-2'))\n\
1121 Decimal('NaN')
1122 >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e-1'))\n\
1123 Decimal('217.0')\n\
1124 >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e-0'))\n\
1125 Decimal('217')\n\
1126 >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e+1'))\n\
1127 Decimal('2.2E+2')\n\
1128 >>> ExtendedContext.quantize(Decimal('217'), Decimal('1e+2'))\n\
1129 Decimal('2E+2')\n\
1130 >>> ExtendedContext.quantize(1, 2)\n\
1131 Decimal('1')\n\
1132 >>> ExtendedContext.quantize(Decimal(1), 2)\n\
1133 Decimal('1')\n\
1134 >>> ExtendedContext.quantize(1, Decimal(2))\n\
1135 Decimal('1')\n\
902 \n"); 1136 \n");
903 1137
904 PyDoc_STRVAR(doc_radix, 1138 PyDoc_STRVAR(doc_radix,
905 "radix($self, /)\n--\n\n\ 1139 "radix($self, /)\n--\n\n\
906 Return Decimal(10), the radix (base) in which the Decimal class does\n\ 1140 Return Decimal(10), the radix (base) in which the Decimal class does\n\
907 all its arithmetic. Included for compatibility with the specification.\n\ 1141 all its arithmetic. Included for compatibility with the specification.\n\
1142 \n\
1143 >>> ExtendedContext.radix()\n\
1144 Decimal('10')\n\
908 \n"); 1145 \n");
909 1146
910 PyDoc_STRVAR(doc_remainder_near, 1147 PyDoc_STRVAR(doc_remainder_near,
911 "remainder_near($self, /, other, context=None)\n--\n\n\ 1148 "remainder_near($self, /, other, context=None)\n--\n\n\
912 Return the remainder from dividing self by other. This differs from\n\ 1149 Returns to be \"a - b * n\", where n is the integer nearest the exact\n\
913 self % other in that the sign of the remainder is chosen so as to minimize\n\ 1150 value of \"x / b\" (if two integers are equally near then the even one\n\
914 its absolute value. More precisely, the return value is self - n * other\n\ 1151 is chosen). If the result is equal to 0 then its sign will be the\n\
915 where n is the integer nearest to the exact value of self / other, and\n\ 1152 sign of a.\n\
916 if two integers are equally near then the even one is chosen.\n\ 1153 \n\
917 \n\ 1154 This operation will fail under the same conditions as integer division\n\
918 If the result is zero then its sign will be the sign of self.\n\ 1155 (that is, if integer division on the same two operands would fail, the\n\
1156 remainder cannot be calculated).\n\
1157 \n\
1158 >>> ExtendedContext.remainder_near(Decimal('2.1'), Decimal('3'))\n\
1159 Decimal('-0.9')\n\
1160 >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('6'))\n\
1161 Decimal('-2')\n\
1162 >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('3'))\n\
1163 Decimal('1')\n\
1164 >>> ExtendedContext.remainder_near(Decimal('-10'), Decimal('3'))\n\
1165 Decimal('-1')\n\
1166 >>> ExtendedContext.remainder_near(Decimal('10.2'), Decimal('1'))\n\
1167 Decimal('0.2')\n\
1168 >>> ExtendedContext.remainder_near(Decimal('10'), Decimal('0.3'))\n\
1169 Decimal('0.1')
1170 >>> ExtendedContext.remainder_near(Decimal('3.6'), Decimal('1.3'))\n\
1171 Decimal('-0.3')\n\
1172 >>> ExtendedContext.remainder_near(3, 11)\n\
1173 Decimal('3')\n\
1174 >>> ExtendedContext.remainder_near(Decimal(3), 11)\n\
1175 Decimal('3')\n\
1176 >>> ExtendedContext.remainder_near(3, Decimal(11))\n\
1177 Decimal('3')\n\
919 \n"); 1178 \n");
920 1179
921 PyDoc_STRVAR(doc_rotate, 1180 PyDoc_STRVAR(doc_rotate,
922 "rotate($self, /, other, context=None)\n--\n\n\ 1181 "rotate($self, /, other, context=None)\n--\n\n\
923 Return the result of rotating the digits of the first operand by an amount\n\ 1182 Returns a rotated copy of a, b times.\n\
924 specified by the second operand. The second operand must be an integer in\n\ 1183 \n\
925 the range -precision through precision. The absolute value of the second\n\ 1184 The coefficient of the result is a rotated copy of the digits in\n\
926 operand gives the number of places to rotate. If the second operand is\n\ 1185 the coefficient of the first operand. The number of places of\n\
927 positive then rotation is to the left; otherwise rotation is to the right.\n\ 1186 rotation is taken from the absolute value of the second operand,\n\
928 The coefficient of the first operand is padded on the left with zeros to\n\ 1187 with the rotation being to the left if the second operand is\n\
929 length precision if necessary. The sign and exponent of the first operand are\n\ 1188 positive or to the right otherwise.\n\
930 unchanged.\n\ 1189 \n\
1190 >>> ExtendedContext.rotate(Decimal('34'), Decimal('8'))\n\
1191 Decimal('400000003')\n\
1192 >>> ExtendedContext.rotate(Decimal('12'), Decimal('9'))\n\
1193 Decimal('12')\n\
1194 >>> ExtendedContext.rotate(Decimal('123456789'), Decimal('-2'))\n\
1195 Decimal('891234567')\n\
1196 >>> ExtendedContext.rotate(Decimal('123456789'), Decimal('0'))\n\
1197 Decimal('123456789')\n\
1198 >>> ExtendedContext.rotate(Decimal('123456789'), Decimal('+2'))\n\
1199 Decimal('345678912')\n\
1200 >>> ExtendedContext.rotate(1333333, 1)\n\
1201 Decimal('13333330')\n\
1202 >>> ExtendedContext.rotate(Decimal(1333333), 1)\n\
1203 Decimal('13333330')\n\
1204 >>> ExtendedContext.rotate(1333333, Decimal(1))\n\
1205 Decimal('13333330')\n\
931 \n"); 1206 \n");
932 1207
933 PyDoc_STRVAR(doc_same_quantum, 1208 PyDoc_STRVAR(doc_same_quantum,
934 "same_quantum($self, /, other, context=None)\n--\n\n\ 1209 "same_quantum($self, /, other, context=None)\n--\n\n\
935 Test whether self and other have the same exponent or whether both are NaN.\n\ 1210 Returns True if the two operands have the same exponent.\n\
936 \n\ 1211 \n\
937 This operation is unaffected by context and is quiet: no flags are changed\n\ 1212 The result is never affected by either the sign or the coefficient of\n\
938 and no rounding is performed. As an exception, the C version may raise\n\ 1213 either operand.\n\
939 InvalidOperation if the second operand cannot be converted exactly.\n\ 1214 \n\
1215 >>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('0.001'))\n\
1216 False\n\
1217 >>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('0.01'))\n\
1218 True\n\
1219 >>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('1'))\n\
1220 False\n\
1221 >>> ExtendedContext.same_quantum(Decimal('Inf'), Decimal('-Inf'))
1222 True\n\
1223 >>> ExtendedContext.same_quantum(10000, -1)\n\
1224 True\n\
1225 >>> ExtendedContext.same_quantum(Decimal(10000), -1)\n\
1226 True\n\
1227 >>> ExtendedContext.same_quantum(10000, Decimal(-1))\n\
1228 True\n\
940 \n"); 1229 \n");
941 1230
942 PyDoc_STRVAR(doc_scaleb, 1231 PyDoc_STRVAR(doc_scaleb,
943 "scaleb($self, /, other, context=None)\n--\n\n\ 1232 "scaleb($self, /, other, context=None)\n--\n\n\
944 Return the first operand with the exponent adjusted the second. Equivalently,\n \ 1233 Returns the first operand after adding the second value its exp.\n\
945 return the first operand multiplied by 10**other. The second operand must be\n\ 1234 \n\
946 an integer.\n\ 1235 >>> ExtendedContext.scaleb(Decimal('7.50'), Decimal('-2'))
1236 Decimal('0.0750')\n\
1237 >>> ExtendedContext.scaleb(Decimal('7.50'), Decimal('0'))\n\
1238 Decimal('7.50')\n\
1239 >>> ExtendedContext.scaleb(Decimal('7.50'), Decimal('3'))\n\
1240 Decimal('7.50E+3')\n\
1241 >>> ExtendedContext.scaleb(1, 4)\n\
1242 Decimal('1E+4')\n\
1243 >>> ExtendedContext.scaleb(Decimal(1), 4)\n\
1244 Decimal('1E+4')\n\
1245 >>> ExtendedContext.scaleb(1, Decimal(4))\n\
1246 Decimal('1E+4')\n\
947 \n"); 1247 \n");
948 1248
949 PyDoc_STRVAR(doc_shift, 1249 PyDoc_STRVAR(doc_shift,
950 "shift($self, /, other, context=None)\n--\n\n\ 1250 "shift($self, /, other, context=None)\n--\n\n\
951 Return the result of shifting the digits of the first operand by an amount\n\ 1251 Returns a shifted copy of a, b times.\n\
952 specified by the second operand. The second operand must be an integer in\n\ 1252 \n\
953 the range -precision through precision. The absolute value of the second\n\ 1253 The coefficient of the result is a shifted copy of the digits\n\
954 operand gives the number of places to shift. If the second operand is\n\ 1254 in the coefficient of the first operand. The number of places\n\
955 positive, then the shift is to the left; otherwise the shift is to the\n\ 1255 to shift is taken from the absolute value of the second operand,\n\
956 right. Digits shifted into the coefficient are zeros. The sign and exponent\n\ 1256 with the shift being to the left if the second operand is\n\
957 of the first operand are unchanged.\n\ 1257 positive or to the right otherwise. Digits shifted into the\n\
1258 coefficient are zeros.\n\
1259 \n\
1260 >>> ExtendedContext.shift(Decimal('34'), Decimal('8'))\n\
1261 Decimal('400000000')\n\
1262 >>> ExtendedContext.shift(Decimal('12'), Decimal('9'))\n\
1263 Decimal('0')\n\
1264 >>> ExtendedContext.shift(Decimal('123456789'), Decimal('-2'))\n\
1265 Decimal('1234567')\n\
1266 >>> ExtendedContext.shift(Decimal('123456789'), Decimal('0'))\n\
1267 Decimal('123456789')\n\
1268 >>> ExtendedContext.shift(Decimal('123456789'), Decimal('+2'))\n\
1269 Decimal('345678900')\n\
1270 >>> ExtendedContext.shift(88888888, 2)\n\
1271 Decimal('888888800')\n\
1272 >>> ExtendedContext.shift(Decimal(88888888), 2)\n\
1273 Decimal('888888800')\n\
1274 >>> ExtendedContext.shift(88888888, Decimal(2))\n\
1275 Decimal('888888800')\n\
958 \n"); 1276 \n");
959 1277
960 PyDoc_STRVAR(doc_sqrt, 1278 PyDoc_STRVAR(doc_sqrt,
961 "sqrt($self, /, context=None)\n--\n\n\ 1279 "sqrt($self, /, context=None)\n--\n\n\
962 Return the square root of the argument to full precision. The result is\n\ 1280 Square root of a non-negative number to context precision.\n\
963 correctly rounded using the ROUND_HALF_EVEN rounding mode.\n\ 1281 \n\
1282 If the result must be inexact, it is rounded using the round-half-even\n\
1283 algorithm.\n\
1284 \n\
1285 >>> ExtendedContext.sqrt(Decimal('0'))\n\
1286 Decimal('0')\n\
1287 >>> ExtendedContext.sqrt(Decimal('-0'))\n\
1288 Decimal('-0')\n\
1289 >>> ExtendedContext.sqrt(Decimal('0.39'))\n\
1290 Decimal('0.624499800')\n\
1291 >>> ExtendedContext.sqrt(Decimal('100'))\n\
1292 Decimal('10')\n\
1293 >>> ExtendedContext.sqrt(Decimal('1'))\n\
1294 Decimal('1')\n\
1295 >>> ExtendedContext.sqrt(Decimal('1.0'))\n\
1296 Decimal('1.0')\n\
1297 >>> ExtendedContext.sqrt(Decimal('1.00'))\n\
1298 Decimal('1.0')\n\
1299 >>> ExtendedContext.sqrt(Decimal('7'))\n\
1300 Decimal('2.64575131')\n\
1301 >>> ExtendedContext.sqrt(Decimal('10'))\n\
1302 Decimal('3.16227766')\n\
1303 >>> ExtendedContext.sqrt(2)\n\
1304 Decimal('1.41421356')\n\
1305 >>> ExtendedContext.prec\n\
1306 9\n\
964 \n"); 1307 \n");
965 1308
966 PyDoc_STRVAR(doc_to_eng_string, 1309 PyDoc_STRVAR(doc_to_eng_string,
967 "to_eng_string($self, /, context=None)\n--\n\n\ 1310 "to_eng_string($self, /, context=None)\n--\n\n\
968 Convert to an engineering-type string. Engineering notation has an exponent\n\ 1311 Convert to a string, using engineering notation if an exponent is needed.\n\
969 which is a multiple of 3, so there are up to 3 digits left of the decimal\n\ 1312 \n\
970 place. For example, Decimal('123E+1') is converted to Decimal('1.23E+3').\n\ 1313 Engineering notation has an exponent which is a multiple of 3. This\n\
971 \n\ 1314 can leave up to 3 digits to the left of the decimal place and may\n\
1315 require the addition of either one or two trailing zeros.\n\
1316
972 The value of context.capitals determines whether the exponent sign is lower\n\ 1317 The value of context.capitals determines whether the exponent sign is lower\n\
973 or upper case. Otherwise, the context does not affect the operation.\n\ 1318 or upper case. Otherwise, the context does not affect the operation.\n\
1319 \n\
1320 >>> ExtendedContext.to_eng_string(Decimal('123E+1'))\n\
1321 '1.23E+3'\n\
1322 >>> ExtendedContext.to_eng_string(Decimal('123E+3'))\n\
1323 '123E+3'\n\
1324 >>> ExtendedContext.to_eng_string(Decimal('123E-10'))\n\
1325 '12.3E-9'\n\
1326 >>> ExtendedContext.to_eng_string(Decimal('-123E-12'))\n\
1327 '-123E-12'\n\
1328 >>> ExtendedContext.to_eng_string(Decimal('7E-7'))\n\
1329 '700E-9'\n\
1330 >>> ExtendedContext.to_eng_string(Decimal('7E+1'))\n\
1331 '70'\n\
1332 >>> ExtendedContext.to_eng_string(Decimal('0E+1'))\n\
1333 '0.00E+3'\n\
974 \n"); 1334 \n");
975 1335
976 PyDoc_STRVAR(doc_to_integral, 1336 PyDoc_STRVAR(doc_to_integral,
977 "to_integral($self, /, rounding=None, context=None)\n--\n\n\ 1337 "to_integral($self, /, rounding=None, context=None)\n--\n\n\
978 Identical to the to_integral_value() method. The to_integral() name has been\n\ 1338 Identical to the to_integral_value() method. The to_integral() name has been\n\
979 kept for compatibility with older versions.\n\ 1339 kept for compatibility with older versions.\n\
980 \n"); 1340 \n");
981 1341
982 PyDoc_STRVAR(doc_to_integral_exact, 1342 PyDoc_STRVAR(doc_to_integral_exact,
983 "to_integral_exact($self, /, rounding=None, context=None)\n--\n\n\ 1343 "to_integral_exact($self, /, rounding=None, context=None)\n--\n\n\
984 Round to the nearest integer, signaling Inexact or Rounded as appropriate if\n\ 1344 Rounds to an integer.
985 rounding occurs. The rounding mode is determined by the rounding parameter\n\ 1345 \n\
986 if given, else by the given context. If neither parameter is given, then the\n\ 1346 When the operand has a negative exponent, the result is the same\n\
987 rounding mode of the current default context is used.\n\ 1347 as using the quantize() operation using the given operand as the\n\
1348 left-hand-operand, 1E+0 as the right-hand-operand, and the precision\n\
1349 of the operand as the precision setting; Inexact and Rounded flags\n\
1350 are allowed in this operation. The rounding mode is taken from the\n\
1351 context.\n\
1352 \n\
1353 >>> ExtendedContext.to_integral_exact(Decimal('2.1'))\n\
1354 Decimal('2')\n\
1355 >>> ExtendedContext.to_integral_exact(Decimal('100'))\n\
1356 Decimal('100')\n\
1357 >>> ExtendedContext.to_integral_exact(Decimal('100.0'))\n\
1358 Decimal('100')\n\
1359 >>> ExtendedContext.to_integral_exact(Decimal('101.5'))\n\
1360 Decimal('102')\n\
1361 >>> ExtendedContext.to_integral_exact(Decimal('-101.5'))\n\
1362 Decimal('-102')\n\
1363 >>> ExtendedContext.to_integral_exact(Decimal('10E+5'))\n\
1364 Decimal('1.0E+6')\n\
1365 >>> ExtendedContext.to_integral_exact(Decimal('7.89E+77'))\n\
1366 Decimal('7.89E+77')\n\
1367 >>> ExtendedContext.to_integral_exact(Decimal('-Inf'))\n\
1368 Decimal('-Infinity')\n\
988 \n"); 1369 \n");
989 1370
990 PyDoc_STRVAR(doc_to_integral_value, 1371 PyDoc_STRVAR(doc_to_integral_value,
991 "to_integral_value($self, /, rounding=None, context=None)\n--\n\n\ 1372 "to_integral_value($self, /, rounding=None, context=None)\n--\n\n\
992 Round to the nearest integer without signaling Inexact or Rounded. The\n\ 1373 Rounds to an integer.\n\
993 rounding mode is determined by the rounding parameter if given, else by\n\ 1374 \n\
994 the given context. If neither parameter is given, then the rounding mode\n\ 1375 When the operand has a negative exponent, the result is the same\n\
995 of the current default context is used.\n\ 1376 as using the quantize() operation using the given operand as the\n\
1377 left-hand-operand, 1E+0 as the right-hand-operand, and the precision\n\
1378 of the operand as the precision setting, except that no flags will\n\
1379 be set. The rounding mode is taken from the context.\n\
1380 \n\
1381 >>> ExtendedContext.to_integral_value(Decimal('2.1'))\n\
1382 Decimal('2')\n\
1383 >>> ExtendedContext.to_integral_value(Decimal('100'))\n\
1384 Decimal('100')\n\
1385 >>> ExtendedContext.to_integral_value(Decimal('100.0'))\n\
1386 Decimal('100')\n\
1387 >>> ExtendedContext.to_integral_value(Decimal('101.5'))\n\
1388 Decimal('102')\n\
1389 >>> ExtendedContext.to_integral_value(Decimal('-101.5'))\n\
1390 Decimal('-102')\n\
1391 >>> ExtendedContext.to_integral_value(Decimal('10E+5'))\n\
1392 Decimal('1.0E+6')\n\
1393 >>> ExtendedContext.to_integral_value(Decimal('7.89E+77'))\n\
1394 Decimal('7.89E+77')\n\
1395 >>> ExtendedContext.to_integral_value(Decimal('-Inf'))\n\
1396 Decimal('-Infinity')\n\
996 \n"); 1397 \n");
997 1398
998 1399
999 /******************************************************************************/ 1400 /******************************************************************************/
1000 /* Context Object and Methods */ 1401 /* Context Object and Methods */
1001 /******************************************************************************/ 1402 /******************************************************************************/
1002 1403
1003 PyDoc_STRVAR(doc_context, 1404 PyDoc_STRVAR(doc_context,
1004 "Context(prec=None, rounding=None, Emin=None, Emax=None, capitals=None, clamp=No ne, flags=None, traps=None)\n--\n\n\ 1405 "Context(prec=None, rounding=None, Emin=None, Emax=None, capitals=None, clamp=No ne, flags=None, traps=None)\n--\n\n\
1005 The context affects almost all operations and controls rounding,\n\ 1406 The context affects almost all operations and controls rounding,\n\
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 Round to an integer.\n\ 1779 Round to an integer.\n\
1379 \n"); 1780 \n");
1380 1781
1381 PyDoc_STRVAR(doc_ctx_to_sci_string, 1782 PyDoc_STRVAR(doc_ctx_to_sci_string,
1382 "to_sci_string($self, x, /)\n--\n\n\ 1783 "to_sci_string($self, x, /)\n--\n\n\
1383 Convert a number to a string using scientific notation.\n\ 1784 Convert a number to a string using scientific notation.\n\
1384 \n"); 1785 \n");
1385 1786
1386 1787
1387 #endif /* DOCSTRINGS_H */ 1788 #endif /* DOCSTRINGS_H */
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+