|
22 | 22 | CircuitPython as well as standard Python, though you should probably |
23 | 23 | use the built in decimal module on standard Python. |
24 | 24 |
|
| 25 | +It still requires a fairly beefy mcu to run. Importing jepler_udecimal |
| 26 | +on an nRF52840 uses about 52kB of heap. |
| 27 | +
|
25 | 28 | * Author(s): jepler |
26 | 29 |
|
27 | 30 | Implementation Notes |
|
37 | 40 | https://github.com/adafruit/circuitpython/releases |
38 | 41 |
|
39 | 42 | This is an implementation of decimal floating point arithmetic based on |
40 | | -the [General Decimal Arithmetic Specification](http://speleotrove.com/decimal/decarith.html) and [IEEE standard 854-1987](http://en.wikipedia.org/wiki/IEEE_854-1987). |
| 43 | +the `General Decimal Arithmetic Specification <http://speleotrove.com/decimal/decarith.html>`_ and `IEEE standard 854-1987 <http://en.wikipedia.org/wiki/IEEE_854-1987>`_. |
41 | 44 |
|
42 | | -Decimal floating point has finite precision with arbitrarily large bounds. |
| 45 | +`Decimal` floating point has finite precision with arbitrarily large bounds. |
43 | 46 |
|
44 | 47 | The purpose of this module is to support arithmetic using familiar |
45 | 48 | "schoolhouse" rules and to avoid some of the tricky representation |
@@ -943,10 +946,12 @@ def __ge__(self, other, context=None): |
943 | 946 | def compare(self, other, context=None): |
944 | 947 | """Compare self to other. Return a decimal value: |
945 | 948 |
|
| 949 | + =============== === ============== |
946 | 950 | a or b is a NaN ==> Decimal('NaN') |
947 | 951 | a < b ==> Decimal('-1') |
948 | 952 | a == b ==> Decimal('0') |
949 | 953 | a > b ==> Decimal('1') |
| 954 | + =============== === ============== |
950 | 955 | """ |
951 | 956 | other = _convert_other(other, raiseit=True) |
952 | 957 |
|
@@ -3272,16 +3277,17 @@ def number_class(self, context=None): |
3272 | 3277 | """Returns an indication of the class of self. |
3273 | 3278 |
|
3274 | 3279 | The class is one of the following strings: |
3275 | | - sNaN |
3276 | | - NaN |
3277 | | - -Infinity |
3278 | | - -Normal |
3279 | | - -Subnormal |
3280 | | - -Zero |
3281 | | - +Zero |
3282 | | - +Subnormal |
3283 | | - +Normal |
3284 | | - +Infinity |
| 3280 | +
|
| 3281 | + * sNaN |
| 3282 | + * NaN |
| 3283 | + * -Infinity |
| 3284 | + * -Normal |
| 3285 | + * -Subnormal |
| 3286 | + * -Zero |
| 3287 | + * +Zero |
| 3288 | + * +Subnormal |
| 3289 | + * +Normal |
| 3290 | + * +Infinity |
3285 | 3291 | """ |
3286 | 3292 | if self.is_snan(): |
3287 | 3293 | return "sNaN" |
@@ -4531,16 +4537,17 @@ def number_class(self, a): |
4531 | 4537 | """Returns an indication of the class of the operand. |
4532 | 4538 |
|
4533 | 4539 | The class is one of the following strings: |
4534 | | - -sNaN |
4535 | | - -NaN |
4536 | | - -Infinity |
4537 | | - -Normal |
4538 | | - -Subnormal |
4539 | | - -Zero |
4540 | | - +Zero |
4541 | | - +Subnormal |
4542 | | - +Normal |
4543 | | - +Infinity |
| 4540 | +
|
| 4541 | + * -sNaN |
| 4542 | + * -NaN |
| 4543 | + * -Infinity |
| 4544 | + * -Normal |
| 4545 | + * -Subnormal |
| 4546 | + * -Zero |
| 4547 | + * +Zero |
| 4548 | + * +Subnormal |
| 4549 | + * +Normal |
| 4550 | + * +Infinity |
4544 | 4551 |
|
4545 | 4552 | >>> c = ExtendedContext.copy() |
4546 | 4553 | >>> c.Emin = -999 |
@@ -4595,26 +4602,11 @@ def plus(self, a): |
4595 | 4602 | return a.__pos__(context=self) |
4596 | 4603 |
|
4597 | 4604 | def power(self, a, b): |
4598 | | - """Raises a to the power of b, to modulo if given. |
4599 | | -
|
4600 | | - With two arguments, compute a**b. If a is negative then b |
4601 | | - must be integral. The result will be inexact unless b is |
4602 | | - integral and the result is finite and can be expressed exactly |
4603 | | - in 'precision' digits. |
4604 | | -
|
4605 | | - With three arguments, compute (a**b) % modulo. For the |
4606 | | - three argument form, the following restrictions on the |
4607 | | - arguments hold: |
4608 | | -
|
4609 | | - - all three arguments must be integral |
4610 | | - - b must be nonnegative |
4611 | | - - at least one of a or b must be nonzero |
4612 | | - - modulo must be nonzero and have at most 'precision' digits |
4613 | | -
|
4614 | | - The result of pow(a, b, modulo) is identical to the result |
4615 | | - that would be obtained by computing (a**b) % modulo with |
4616 | | - unbounded precision, but is computed more efficiently. It is |
4617 | | - always exact. |
| 4605 | + """Raises a to the power of b |
| 4606 | +
|
| 4607 | + If a is negative then b must be integral. The result will be inexact |
| 4608 | + unless b is integral and the result is finite and can be expressed |
| 4609 | + exactly in 'precision' digits. |
4618 | 4610 |
|
4619 | 4611 | >>> c = ExtendedContext.copy() |
4620 | 4612 | >>> c.Emin = -999 |
|
0 commit comments